Flutter 全屏背景图(包括 Appbar 和 状态栏)

class _HomePageState extends State<HomePage>{
@override
Widget build(BuildContext context) {
// 获取屏幕宽高
final size = MediaQuery.of(context).size;
final width = size.width;
final height = size.height;

return Container(
width,
height: height,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('https://m.airchina.com.cn:9062/fu/yx/20200804/5bcecdbba76d41f19d5913aa7684469a.jpg'),
fit: BoxFit.cover,
),
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
),
body: Container(
width,
child: Text('hello'),
),
),
);
}
}
原文地址:https://www.cnblogs.com/diweinan/p/13502163.html