当前,抽屉页眉处于固定高度。如何降低抽屉标头的高度以适合其子容器的内容?
child: ListView(
padding: EdgeInsets.zero,
children: [
DrawerHeader(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.account_box),
Text(
'Name Here',
style: Theme.of(context).textTheme.headline5,
),
Text('Email Here'),
]),
decoration: BoxDecoration(
color: Theme.of(context).accentColor,
),
),
答案 0 :(得分:0)
您可以将标题包装在SizedBox或Container中。 一个建议:将标题包装在列内,而不是在列表视图中,因为标题不应滚动。将listview设为列的第二个子代。
答案 1 :(得分:0)
您可以使用DrawerHeader
小部件包装Container
。
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
Container(
height: 120,
child: DrawerHeader(
child: Column(
children: [
Icon(Icons.account_box),
Text(
'Name Here',
style: Theme.of(context).textTheme.headline5,
),
Text('Email Here'),
],
),
decoration: BoxDecoration(
color: Colors.blue,
),
),
),
],
),
),
答案 2 :(得分:0)
您可以使用Container小部件将其包装
容器( 高度:140.0,
child: DrawerHeader(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.account_box),
Text(
'Name Here',
style: Theme.of(context).textTheme.headline5,
),
Text('Email Here'),
]),
decoration: BoxDecoration(
color: Colors.blue[300],
),
)),