繁体   English   中英

FLUTTER:如何为应用程序制作持久性背景图像

[英]FLUTTER: How to make a persitent background image for app

我想为我的应用程序中的所有屏幕使用相同的背景图像,使其成为 static,这样当我使用导航器时它就不会移动。 你知道怎么做吗?

您可以定义一个带有背景图像的小部件,并在其上堆叠您想要的屏幕。

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,
        ],
      ),
    );
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM