flutter - FLUTTER:如何为应用制作持久性背景图片
问题描述
我想为我的应用程序中的所有屏幕使用相同的背景图像,使其成为静态的,这样当我使用导航器时它就不会移动。你知道怎么做吗?
解决方案
您可以定义一个带有背景图像的小部件,并在其上堆叠您想要的屏幕。
class BackgroundPage extends StatelessWidget {
const BackgroundPage({
Key key,
@required this.child,
}) : super(key: key);
/// The widget to display
final Widget child;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: ExactAssetImage('image.png'),
),
),
),
child,
],
),
);
}
}
推荐阅读
- java - ByteBuddy 是否可以拦截由带有注释的接口声明的方法?
- sparql - 我如何编写一个查询 om SPARQL 来获取类的详细信息,然后获取 iots 子类的详细信息?
- firebase - Flutter - 在 Cloud Firestore 中更新地图和数组的值
- angular - 如何将图像存储在 PostGreSQL DB 中?
- javascript - How to change maxlength attributes for all classes of "field answer"
- python-3.x - 如何在没有 MissingRequiredArgument 错误的情况下操作 @client.command() 部分中的 message.content
- erlang - Core Erlang 的 `letrec` 是干什么用的?
- aspnetboilerplate - ASPNET Boilerplate,扩展审计日志
- python - 我可以同时而不是顺序地在列表上执行 python 代码吗?
- r - 如何从R中的重复数组中只保留一个值(最新的)