我想在抽屉里显示一个菜单网格但是卡住了
当在页面中使用GridView.count然后它的工作,如果在抽屉内使用相同,那么它显示一些渲染问题
Scaffold scaffold = Scaffold(
appBar: AppBar(
title: Text('X'),
),
drawer: Drawer(
child: Column(
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text('X'),
accountEmail: Text('[email protected]'),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.black,
child: Text(
'X',
style: TextStyle(fontSize: 40.0),
),
),
),
GridView.count(
crossAxisCount: 4,
children: <Widget>[
Text('A')
],
),
],
)),
);
预先感谢您的帮助
将GridView的shrinkWrap属性设置为true。
GridView.count(
shrinkWrap: true,
crossAxisCount: 4,
children: <Widget>[
Text('A'),
],
),
这会将窗口小部件高度限制为仅需要的高度。