flutter - 如何在颤动中更改为我的drawerMenuBar背景颜色?
问题描述
下面是我的代码,我已经能够将drawerheader更改为黑色,但是当我color: Colors.grey[800]
为listtiles做的时候,只有它的区域被灰色覆盖,剩余的额外空间是白色的..
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
Container(
height: 130,
child: DrawerHeader(
child: new Text(
'Hi Bolade',
style: TextStyle(color: Colors.white),
),
decoration: BoxDecoration(
color: Colors.black,
),
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.grey[800],
),
child: Column(
children: [
ListTile(
leading: Icon(Icons.home),
title: Text('Dashboard'),
onTap: () {},
),
ListTile(
leading: FaIcon(FontAwesomeIcons.tree),
title: Text('Savings'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.trending_up),
title: Text('Investments'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.account_box_sharp),
title: Text('Products'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.wallet_membership),
title: Text('Wallet'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.card_giftcard),
title: Text('Cards & Bank'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.card_giftcard),
title: Text('Share & Earn'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.chat),
title: Text('Support'),
onTap: () {},
),
],
),
),
],
),
),
在此处输入图像描述 当前状态的图像在下面
解决方案
将您的列表视图保存在 Container 中并为该容器指定颜色。
Container(
color: Colors.grey[800]
child: ListView(
....
)
)