make a page scrollable flutter code example
Example 1: make listview not scrollable flutter
ListView(
physics: NeverScrollableScrollPhysics(), // <-- this will disable scroll
shrinkWrap: true,
children: [],
),
Example 2: make scaffold scrollable flutter
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('News'),
),
body: SingleChildScrollView( // <-- wrap this around
child: Column(
children: [
],
),
));
}
Example 3: viewportConstraints
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
// A fixed-height child.
color: const Color(0xff808000), // Yellow
height: 120.0,
),
Container(
// Another fixed-height child.
color: const Color(0xff008000), // Green
height: 600.0,
),
],
),
),
);
},
);
}
Example 4: how to scroll screen in flutter
// Add SingleChildScrollView or add items in ListView
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('News'),
),
body: SingleChildScrollView(
child: Column(
children: [
],
),
));
}