どうも、ちょげ(@chogetarou)です。
DrawerHeaderの高さを設定する方法を紹介します。
方法

DrawerHeaderの高さを設定するには、SizedBoxもしくはContainerを使います。
まず、DrawerHeaderをSizedBoxもしくはContainerでラップします。
そして、SizedBoxもしくはContainerの引数「height」で高さを指定します。
SizedBox(
height: /*高さ*/,
child: DrawerHeader(),
)
これでDrawerHeaderの高さを設定することが出来ます。
以下は、使用例です。
使用例
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(),
drawer: Drawer(
child: ListView(
children: [
SizedBox(
height: 80,
child: DrawerHeader(
decoration: BoxDecoration(),
child: Container(
color: Colors.yellow,
),
),
),
ListTile(
leading: Icon(Icons.person),
title: Text('Person1'),
),
ListTile(
leading: Icon(Icons.person),
title: Text('Person2'),
),
ListTile(
leading: Icon(Icons.person),
title: Text('Person3'),
),
],
),
),
),
);
}

コメント