退出底部抽屉导航抖动

问题描述 投票:0回答:1

我想在抽屉式导航的底部进行注销和设置,但是我尝试了很多建议,但根本无法使用有什么建议吗?

这是我的抽屉导航

Drawer(
      child: ListView(
        padding: EdgeInsets.zero,
        children: <Widget>[
          _createHeader(),
          _createDrawerItem(icon: Icons.event, text: 'Event', onTap: () => Navigator.pushReplacementNamed(context, Routes.event)
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.end,
            children: <Widget>[
              _createFooterItem(icon: Icons.event, text: 'Settings', onTap: () => Navigator.pushReplacementNamed(context, Routes.event)),
              _createFooterItem(icon: Icons.event, text: 'Logout', onTap: () => Navigator.pushReplacementNamed(context, Routes.event))
            ],
          ),
        ],
      ),
    );

这是我的标题小部件

Widget _createHeader() {
    return DrawerHeader(
        margin: EdgeInsets.zero,
        padding: EdgeInsets.zero,
        decoration: BoxDecoration(
            image: DecorationImage(
                fit: BoxFit.fill,
                image: AssetImage('res/images/drawer_header_background.png'))),
        child: Stack(children: <Widget>[
          Positioned(
              bottom: 12.0,
              left: 16.0,
              child: Text("Flutter Step-by-Step",
                  style: TextStyle(
                      color: Colors.white,
                      fontSize: 20.0,
                      fontWeight: FontWeight.w500))),
        ]));
  }

这是我的页脚项目小部件

Widget _createFooterItem({IconData icon, String text, GestureTapCallback onTap}){
    return ListTile(
      title: Row(
        children: <Widget>[
          Icon(icon),
          Padding(
            padding: EdgeInsets.only(left: 8.0),
            child: Text(text),
          )
        ],
      ),
      onTap: onTap,
    );
  }
flutter dart navigation-drawer flutter-layout
1个回答
1
投票

您可以将ListView更改为Column,然后添加带有子项ExpandedContainer小部件

Drawer(
        child: Column( // Changed this to a Column from a ListView
          children: <Widget>[
            _createHeader(),
            ListTile(title: Text('First item')),
            Expanded(child: Container()), // Add this to force the bottom items to the lowest point
            Column(
              children: <Widget>[
                _createFooterItem(
                    icon: Icons.event,
                    text: 'Settings',
                    onTap: () => Navigator.pushReplacementNamed(context, '/')),
                _createFooterItem(
                    icon: Icons.event,
                    text: 'Logout',
                    onTap: () => Navigator.pushReplacementNamed(context, '/'))
              ],
            ),
          ],
        ),
      );
© www.soinside.com 2019 - 2024. All rights reserved.