Flutter align button to bottom of Drawer

后端 未结 6 605
慢半拍i
慢半拍i 2021-02-03 21:29

I\'m trying to have a Widget align to the bottom of my NavDrawer while still keeping a DrawerHeader and a list at the top of the Drawer. Here\'s what I\'m trying:



        
6条回答
  •  南方客
    南方客 (楼主)
    2021-02-03 22:28

    look whats the problem with your code you have added a Column as a Child to the Drawer so whatever you add in it are vertically placed and The height of Column is by default shrunk to its children's height and it gets larger as the child gets, so there's no point in adding an Align inside a Column

    The Simpler Solution Would be to use an Expanded Widget that takes the remaining Space Look I have used a Column and added A widget above and below the Expanded Widget.

          Drawer(
                elevation: 1.5,
                child: Column(children: [
                  DrawerHeader(
                      decoration: BoxDecoration(
                    color: Colors.redAccent,
                  )),
                  Expanded(
                      child: ListView(
                    padding: EdgeInsets.zero,
                    children: [
                      ListTile(
                        title: Text('My Cart'),
                        leading: Icon(Icons.shopping_cart),
                        onTap: () {},
                      ),
                      ListTile(
                        title: Text('My Orders'),
                        leading: Icon(Icons.add_shopping_cart),
                        onTap: () {},
                      ),
                      ListTile(
                          title: Text('Logout'),
                          leading: Icon(Icons.exit_to_app),
                          onTap: () {})
                    ],
                  )),
                  Container(
                    color: Colors.black,
                    width: double.infinity,
                    height: 0.1,
                  ),
                  Container(
                      padding: EdgeInsets.all(10),
                      height: 100,
                      child: Text("V1.0.0",style: TextStyle(fontWeight: FontWeight.bold),)),
                ])),
    

提交回复
热议问题