flutter全屏背景图(包括appbar和状态栏)以及沉浸状态栏的设置
上面这个主要思路: 用一个 Container 组件 设置一张背景图, 包裹 Scaffold 组件, 在 Scaffold 组件中设置 背景色 和 tabbar 背景色 都为透明,然后设置 tabbar 没有阴影
即: elevation: 0, 最后设置沉浸式状态栏, 记录一下,以前用过,忘记了
class _HomeState extends State<Home> { @override Widget build(BuildContext context) { SelfAdapt _adapt = SelfAdapt.init(context); return Container( width: _adapt.width, height: _adapt.height, decoration: BoxDecoration( image: DecorationImage( image: NetworkImage(‘https://img.zcool.cn/community/0372d195ac1cd55a8012062e3b16810.jpg‘), fit: BoxFit.cover, ), ), child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, // title: Text(‘首页‘), ), drawer: MyDrawer(), body: Container( width: _adapt.width, padding: _adapt.setfromLTRB(100, 0, 100, 0), child: Text(‘hello‘), ), ), ); } }
flutter设置沉浸式状态栏