FrancescoPenasa
FrancescoPenasa

Reputation: 280

Flutter: how to add anchored button at the bottom of a page after a ListView

This is my code until now, I would like to anchor the Material button to the bottom of the Screen, so I would like that my Column to take all the available space on the screen, I cannot use the Scaffold arguments like bottomsheet for this, since it is another widget and there is some separate logic that requires the button to be in the same place as the listView

Scaffold(
  body: Column(children[
    Container(),
    Container(),
    _myWidget(),
]));
Widget _myWidget(){
return Expanded(
  child: Column(
    children:[
      Container(),
      ListView.builder( /* more_code*/ ),
      Align(
        alignment: Alignment.bottomCenter,
        child: MaterialButton(/* more_code */)
      ),],),
);

This is how the button is now, I want to anchor it to the bottom enter image description here

Upvotes: 3

Views: 1132

Answers (1)

Jahidul Islam
Jahidul Islam

Reputation: 12575

Write with stack instead of column

Widget _myWidget(){
return Expanded(
  child: Stack(
    children:[
      Container(),
      ListView.builder( /* more_code*/ ),
      Align(
        alignment: Alignment.bottomCenter,
        child: MaterialButton(/* more_code */)
      ),],),
);

Upvotes: 1

Related Questions