【Flutter】沉浸式导航

效果

结构是使用Stack布局先给后面的控件弄个图片的背景,之后再上Scaffold,再将相关的组件背景设为透明即可. 

代码

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Image.network(
            'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594978254437&di=0efdd0c88ec953a59059c6b59b83cd94&imgtype=0&src=http%3A%2F%2Ft8.baidu.com%2Fit%2Fu%3D2638456903%2C612126385%26fm%3D193'),
        Scaffold(
          backgroundColor: Colors.transparent,
          appBar: AppBar(
            iconTheme: IconThemeData(color: Colors.white),
            brightness: Brightness.dark,//dart时状态栏颜色为亮色
            backgroundColor: Colors.transparent,
          ),
          body: Column(
            children: [
              SizedBox(
                height: 150,
              ),
              Expanded(
                  child: Container(
                width: double.infinity,
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius:
                        BorderRadius.vertical(top: Radius.circular(17))),
                child: Column(
                  children: [
                    SizedBox(
                      height: 8,
                    )
                  ],
                ),
              ))
            ],
          ),
        )
      ],
    );
  }
}

 

你可能感兴趣的:(Flutter)