Flutter DrawerHeaderの高さを設定するサンプル
環境
Windows11 pro 64bit
Flutter 3.3.7
構文
SizedBox(
height: 高さ,
child: DrawerHeader(),
DrawerHeaderの高さを設定するには、SizedBoxを使います。
DrawerHeaderをSizedBoxでラップします。
SizedBozははContainerの引数「height」で高さを指定します。
使用例
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(),
drawer: Drawer(
child: ListView(
children: [
SizedBox(
height: 60,
child: DrawerHeader(
decoration: BoxDecoration(),
child: Container(
color: Colors.red,
),
),
),
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(),
drawer: Drawer(
child: ListView(
children: [
SizedBox(
height: 60,
child: DrawerHeader(
decoration: BoxDecoration(),
child: Container(
color: Colors.red,
),
),
),
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( appBar: AppBar(), drawer: Drawer( child: ListView( children: [ SizedBox( height: 60, child: DrawerHeader( decoration: BoxDecoration(), child: Container( color: Colors.red, ), ), ),