我要实现此抽屉标题
但是我的抽屉有很大的空间,如何去除抽屉顶部多余的空间?
编码
class AppDrawer extends HookWidget {
@override
Widget build(BuildContext context) {
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
_createHeader(),
_createDrawerItem(
icon: Icons.contacts,
text: 'Contacts',
onTap: () {},
),
_createDrawerItem(
icon: Icons.event,
text: 'Events',
onTap: () {},
),
],
),
);
}
Widget _createDrawerItem(
{required IconData icon,
required String text,
required GestureTapCallback onTap}) {
return ListTile(
title: Row(
children: <Widget>[
Icon(icon),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(text),
)
],
),
onTap: onTap,
);
}
Widget _createHeader() {
return const DrawerHeader(
decoration: BoxDecoration(color: Colors.green),
child: ListTile(
title: Text("Name"),
subtitle: Text("Email"),
dense: true,
leading: CircleAvatar(child: Icon(Icons.people)),
));
}
}
忽略此行epfokeofkpekf efewfefefefefefefefefewf fewfef fefef fefjoej jifjeojfo oijoewfjoej oijfoijfoiejf rvw
2条答案
按热度按时间nvbavucw1#
除了DrawerHeader,您还可以使用Container或SizedBox来根据需要更改其高度。
hgtggwj02#
你可以使用
Container()
来代替DrawerHeader()
。示例: