Android 抽屉标题图像未填充屏幕
因此,我在我的flutter应用程序中构建了一个抽屉(我第一次使用它),然后有什么事情困扰着我。因此,当您将图像放入抽屉标题时,图像本身不会到达屏幕顶部 图片: 这是我抽屉的代码:Android 抽屉标题图像未填充屏幕,android,ios,flutter,dart,flutter-layout,Android,Ios,Flutter,Dart,Flutter Layout,因此,我在我的flutter应用程序中构建了一个抽屉(我第一次使用它),然后有什么事情困扰着我。因此,当您将图像放入抽屉标题时,图像本身不会到达屏幕顶部 图片: 这是我抽屉的代码: drawer: Drawer( child: ListView( children: <Widget>[ DrawerHeader( padding: EdgeInsets.zero, d
drawer: Drawer(
child: ListView(
children: <Widget>[
DrawerHeader(
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/images/fighters.jpg")),
),
child: Center(
child: Text(
"Menu",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 30,
),
),
),
)
],
),
),
抽屉:抽屉(
子:ListView(
儿童:[
抽屉阅读器(
填充:EdgeInsets.zero,
装饰:盒子装饰(
颜色:颜色,蓝色,
图像:装饰图像(
适合:BoxFit.cover,
图片:AssetImage(“assets/images/fighters.jpg”),
),
儿童:中心(
子:文本(
“菜单”,
样式:TextStyle(
颜色:颜色,白色,
fontWeight:fontWeight.bold,
尺寸:30,
),
),
),
)
],
),
),
代码中没有任何填充内容
请帮我解决这个问题,谢谢你的帮助 试试这个:
drawer: SafeArea(
top: false,
child: Drawer(..),
),
或
使用列而不是Listview
drawer: Drawer(
child: Column(
children: <Widget>[
DrawerHeader(
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/images/main_top.png")),
),
child: Center(
child: Text(
"Menu",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 30,
),
),
),
)
],
),
),
抽屉:抽屉(
子:列(
儿童:[
抽屉阅读器(
填充:EdgeInsets.zero,
装饰:盒子装饰(
颜色:颜色,蓝色,
图像:装饰图像(
适合:BoxFit.cover,
图片:AssetImage(“assets/images/main_top.png”),
),
儿童:中心(
子:文本(
“菜单”,
样式:TextStyle(
颜色:颜色,白色,
fontWeight:fontWeight.bold,
尺寸:30,
),
),
),
)
],
),
),
感谢您的回复,但当我将顶部:false放在抽屉中时,我的图像仍然保持不变。更新的答案,请尝试。谢谢!我添加了这个,现在图像触顶。谢谢你的回答,伙计!欢迎兄弟~~~~尝试使用BoxFit.fill或fitHeight。此外,将抽屉阅读器放在listview中是不明智的。而是使用列,然后使用列表视图。
drawer: Drawer(
child: Column(
children: <Widget>[
DrawerHeader(
padding: EdgeInsets.zero,
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
fit: BoxFit.cover,
image: AssetImage("assets/images/main_top.png")),
),
child: Center(
child: Text(
"Menu",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 30,
),
),
),
)
],
),
),