Flutter 颤振抽屉背景图像
我想知道我是否可以使用背景图像而不是flutter应用程序抽屉标题中的颜色,有什么办法吗Flutter 颤振抽屉背景图像,flutter,flutter-layout,flutter-navigation,flutter-appbar,flutter-image,Flutter,Flutter Layout,Flutter Navigation,Flutter Appbar,Flutter Image,我想知道我是否可以使用背景图像而不是flutter应用程序抽屉标题中的颜色,有什么办法吗 我可以自定义颜色,但我想知道是否有任何属性可以使用自定义图像更改颜色。您可以使用抽屉阅读器中的装饰将图像设置为抽屉标题 return Scaffold( appBar: AppBar(title: Text(title)), body: Center(child: Text('some text')), drawer: Drawer( // Add a
我可以自定义颜色,但我想知道是否有任何属性可以使用自定义图像更改颜色。您可以使用抽屉阅读器中的装饰将图像设置为抽屉标题
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text('some text')),
drawer: Drawer(
// Add a ListView to the drawer. This ensures the user can scroll
// through the options in the drawer if there isn't enough vertical
// space to fit everything.
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
image: AssetImage("assets/gold.jpg"),
fit: BoxFit.cover)
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
],
),
),
);
返回脚手架(
appBar:appBar(标题:文本(标题)),
正文:居中(子:文本(“某些文本”),
抽屉(
//向抽屉添加列表视图。这确保用户可以滚动
//如果没有足够的垂直线,请通过抽屉中的选项
//空间适合所有东西。
子:ListView(
//重要提示:从ListView中删除任何填充。
填充:EdgeInsets.zero,
儿童:[
抽屉阅读器(
子项:文本(“抽屉标题”),
装饰:盒子装饰(
颜色:颜色,蓝色,
图像:装饰图像(
图片:AssetImage(“assets/gold.jpg”),
安装:BoxFit.盖)
),
),
列表砖(
标题:文本(“项目1”),
onTap:(){
//更新应用程序的状态
// ...
//然后关上抽屉
Navigator.pop(上下文);
},
),
列表砖(
标题:文本(“项目2”),
onTap:(){
//更新应用程序的状态
// ...
//然后关上抽屉
Navigator.pop(上下文);
},
),
],
),
),
);
你也看到了吗
声明其中的容器。这对我很有用:
Drawer(
elevation: 5,
child: Container(
width: 200,
height: 100,
decoration: BoxDecoration(
image: new DecorationImage(
image: AssetImage("lib/assets/bookcover.jpg"),
fit: BoxFit.cover,
),
),