Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振:如何为应用程序制作持久的背景图像_Flutter_Flutter Layout - Fatal编程技术网

Flutter 颤振:如何为应用程序制作持久的背景图像

Flutter 颤振:如何为应用程序制作持久的背景图像,flutter,flutter-layout,Flutter,Flutter Layout,我想对我的应用程序中的所有屏幕使用相同的背景图像,使其静止,以便在使用navigator时不会移动。你知道怎么做吗?你可以用背景图像定义一个小部件,并将你想要的屏幕堆叠在上面 class BackgroundPage extends StatelessWidget { const BackgroundPage({ Key key, @required this.child, }) : super(key: key); /// The widget to displa

我想对我的应用程序中的所有屏幕使用相同的背景图像,使其静止,以便在使用navigator时不会移动。你知道怎么做吗?

你可以用背景图像定义一个小部件,并将你想要的屏幕堆叠在上面

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,
        ],
      ),
    );
  }
}
class BackgroundPage扩展了无状态小部件{
常数背景页({
关键点,
@需要这个孩子,
}):super(key:key);
///要显示的小部件
最后一个孩子;
@凌驾
小部件构建(构建上下文){
返回脚手架(
主体:堆栈(
儿童:[
容器(
装饰:盒子装饰(
图像:装饰图像(
图像:ExactAssetTime('image.png'),
),
),
),
小孩
],
),
);
}
}
这将有助于: