Flutter | 给 Container 设置背景图片

decoration 里面设置 image 即可:

Container(
	width: 100,
	height: 100,
	alignment: Alignment.center,
	child: Text('有背景图'),
	decoration: BoxDecoration(
		color: Colors.red,
		image: DecorationImage(
			image: AssetImage('assets/images/dialog_success.png'),
			fit: BoxFit.fill, // 完全填充
		),
	),
),

你可能感兴趣的:(Flutter,flutter)