如何在列表视图中扩展列以覆盖导航抽屉中屏幕的所有剩余空间

时间:2019-04-10 16:49:15

标签: dart flutter

正在以波动的方式构建导航Ctrl + Enter,其中一些项目位于顶部,而某些项目位于抽屉的底部。但是在Drawer中,无法在ListView底部添加Column小部件。我什至尝试扩展,但是并不能解决问题。

Drawer

最后一个用Drawer( child: ListView( children: <Widget>[ Container( margin: const EdgeInsets.only(top: 10, right: 10.0, left: 10.0), padding: const EdgeInsets.only(bottom: 10), child: Stack( alignment: Alignment.topRight, children: <Widget>[ Center( child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ SizedBox(height: 30), CircleAvatar( radius: 45, child: Text( 'AC', style: TextStyle(fontSize: 40), ), ), ], ), ), ], ), ), Divider(), Column(children: _drawerOptions), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: <Widget>[ Text( AppStrings.termsAndConditions, style: TextStyle( fontSize: 16.0, color: Color.fromARGB(255, 39, 39, 39), ), ) ], ), ) ], ), ); 包装的窗口小部件Column是将Expanded放在Column的底部,但这没有发生。

有人可以提出任何解决方案吗?

1 个答案:

答案 0 :(得分:2)

您应该使用另一种方法,使用ListViewColumn放在Expanded内,这是完整的工作代码。

Drawer(
  child: Column(
    children: <Widget>[
      Container(
        margin: const EdgeInsets.only(top: 10, right: 10.0, left: 10.0),
        padding: const EdgeInsets.only(bottom: 10),
        child: Stack(
          alignment: Alignment.topRight,
          children: <Widget>[
            Center(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  SizedBox(height: 30),
                  CircleAvatar(
                    radius: 45,
                    child: Text(
                      'AC',
                      style: TextStyle(fontSize: 40),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      Divider(),
      Expanded(child: ListView(children: _drawerOptions)),
      Spacer(),
      Text("Terms and conditions"),
    ],
  ),
),