dart - Flutter:AppBar 背景图片
问题描述
是否可以向 Scaffold 的 AppBar 添加背景图像?我知道 sliver,但是当您向下滚动时,图像会被隐藏并且 AppBar 会改变颜色,对吗?所以我想知道这是否可能,如果没有,是否有任何现有的解决方法?谢谢!
解决方案
而不是使用Stack
像Zulfiqar 这样flexibleSpace
的小部件,而是在小部件的参数中传递您的背景图像AppBar
:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('App Bar!'),
flexibleSpace: Image(
image: AssetImage('assets/image.png'),
fit: BoxFit.cover,
),
backgroundColor: Colors.transparent,
),
body: Container(),
);
}
推荐阅读
- python-3.x - 如何制作一个需要 3 秒然后在控制台中打印的程序
- addition - 如何使用 CNF 描述加法
- laravel - 更新 laravel 6.2 [App\Http\Controllers\Auth\ConfirmPasswordController] 后不存在
- javascript - 在分数数字作为步骤的情况下,Material 的 Slider API 无法正确渲染滑块,标记 | 材质ui | 滑块 | 反应
- fabricjs - 如何知道用于 fabricjs 自定义构建的内容
- angular - 使用 usimg NPM install 命令未安装 Npm 包
- angular7 - 我们可以将任何 HTML 表格数据转换为 Json 文件吗?我想把 HTML Table 的数据保存到 Json 文件中可以吗?
- android - 无法连接到 Android Studio 上的本地 API
- reactjs - 创建反应应用程序在 ubuntu 14.04 中不起作用
- wpf - 如何通过触发器改变 WrapPanel 的方向属性?