-
效果
-
代码
// DecoratedBox装饰容器
class DecoratedBoxDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 200,
height: 200,
// 添加装饰
child: DecoratedBox(
// 装饰定位是位于前背景还是后背景
position: DecorationPosition.background,
child: Text('定位展示', style: TextStyle(fontSize: 28, color: Colors.green),),
decoration: BoxDecoration(
// 背景色
color: Colors.green,
// 设置背景图片
image: DecorationImage(
image: ExactAssetImage('assets/view.jpg'),
// 填充格式
fit: BoxFit.cover,
),
// 边框弧度
// borderRadius: BorderRadius.circular(10.0),
border: Border.all(
// 边框颜色
color: Colors.red,
// 边框粗细
width: 6
),
// 边框样式
shape: BoxShape.circle
),
),
);
}
}