Fulutter set rounded corner background image & Container set border, rounded corner, shadow
How to implement a background image in Flutter? How to achieve a background image with rounded corners?
Fulutter set rounded corner background image
Using Container's decoration can easily set the rounded corner size of an easy component background image:
Container(
decoration: ShapeDecoration(
image: new DecorationImage(
//设置背景图片
image: AssetImage("assets/images/task_icon.jpg"),
fit: BoxFit.cover,
),
//设置圆角
shape:RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(20)),
),
//设置边距
margin: EdgeInsets.only(top: 16, left: 20, right: 20),
child: new Card(
color: Colors.transparent,
……
)
Use Container to set borders, rounded corners, and shadows
What if we want to set the border, rounded corners and shadow of a container component?
Implementation code:
Container(
decoration: BoxDecoration(
//设置边框
border: new Border.all(color: Color(0xFFFF0000), width: 0.5),
//背景颜色
color: Colors.white,
//设置圆角
borderRadius: new BorderRadius.circular((5.0)),
//设置阴影
boxShadow: [BoxShadow(color: Colors.lightGreen, offset: Offset(1.0, 1.0), blurRadius: 1.0, spreadRadius: 1.0), ],
),
)
**PS: For more exciting content, please check --> "Flutter Development"
**PS: For more exciting content, please check --> "Flutter Development"
**PS: For more exciting content, please check --> "Flutter Development"