I tried flutter web, and I want achieve this layout:
Column
- Navbar
- ListView
- Text
- ListView builder
- Footer
It works fine when the listview builder item is enough to make the page scrollable, but when there are only a few items, my footer is not placed at the bottom of the page, any idea to achieve this?
here I include sample code to visualize what I tried to achieve (change the itemCount to 100 for scrollable, and itemCount = 5 is the problem -> green bar stay at the bottom when not scrollable)
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children:[
Container(
height: 50, color:Colors.red),
SizedBox(height: 30),
Expanded(
child: ListView(
children:[
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index)=>Container(height: 10, color: index.isOdd?Colors.blue:Colors.red),
itemCount: 5
),
SizedBox(height: 30),
Container(height: 50, color: Colors.green)
]
),
)
]
)
);
2
Answers
I don’t know if it works in flutter web, but have you tried putting it inside the Scaffold’s bottomNavigationBar property? or you can even use a Stack and position the widget with Positioned at the bottom.
The Scaffold widget in flutter has a property called a CustomScrollView so Instead of user a column and multiple listviews your code would look like this