所以我在我的 flutter 应用程序中构建了一个抽屉(我第一次使用它),然后一些事情困扰着我。因此,当您将图像放入抽屉标题时,图像本身不会到达屏幕顶部。
图片:
这是我的抽屉代码:
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,
),
),
),
)
],
),
),
我没有任何填充代码
请帮我解决这个问题,感谢您的帮助,谢谢!
答案 0 :(得分:0)
试试这个:
drawer: SafeArea(
top: false,
child: Drawer(..),
),
或
MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView
答案 1 :(得分:0)
使用列而不是列表视图。
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,
),
),
),
)
],
),
),