flutter - Flutter:为全背景应用一个渐变
问题描述
如何将此处的渐变应用到应用程序背景?你能看到应用栏和脚手架主体上的渐变向下移动,就像它们是一个小部件而不是两个每个都有自己颜色的小部件一样?
解决方案
您需要使用容器作为脚手架的背景来添加渐变。您也可以使用Opacity小部件使容器或任何小部件透明。但这是您正在寻找的确切解决方案:
Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF282a57), Colors.black],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(20, 50, 20, 0),
child: Container(
child: Row(
children: <Widget>[
Icon(Icons.menu,color: Colors.white,),
Spacer(),
Text("Expense",style: TextStyle(color: Colors.white,fontSize: 18,)),
Spacer(),
Icon(Icons.clear, color: Colors.white,)
],
),
),
),
],
),
)
推荐阅读
- flask - 运行烧瓶应用程序后覆盆子重新启动
- elasticsearch - Elasticsearch 复制索引数据到文件 curl 查询
- python - Matplotlib:如何以正确的方式删除颜色条?
- c++ - 在 C++ 中传递只读参数:复制或引用,或
- c# - 如何查询 Azure 应用服务中的性能指标?
- python - 我需要我的 Django get_absolute_url 来做两件不同的事情
- jquery - 如何根据下拉输入显示/隐藏 SharePoint 列?
- c++ - cmake find_package relative path in CMakeLists.txt subfolder
- javascript - 如何将文件加载到内存中 node.js?还是将sqlite数据库放入内存?
- python - 选择至少包含一个字符串的字符串作为子字符串