我正在尝试制作一个屏幕,其中所有底部边框(底部的最后一个边框除外)的左右边框都应为圆形。
我可以创建圆角边框,但是,如何隐藏顶部边框的背景色并将其连接到先前的小部件?
正如您在下图中所看到的,我的边框是圆形的,但是背景颜色(绿色)出现在蓝色和红色之间。如何隐藏它?
我如何实现边界连接?
代码
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.green,
appBar: AppBar(
elevation: 0,
automaticallyImplyLeading: true,
actions: <Widget>[
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
],
),
body: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
child: Container(
height: 250.0,
margin: const EdgeInsets.only(
bottom: 6.0), //Same as `blurRadius` i guess
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
color: Colors.blue,
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(0.0, 1.0), //(x,y)
blurRadius: 6.0,
),
],
),
),
),
ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
child: Container(
height: 300.0,
margin: const EdgeInsets.only(
bottom: 6.0), //Same as `blurRadius` i guess
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
color: Colors.red,
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(0.0, 1.0), //(x,y)
blurRadius: 6.0,
),
],
),
),
),
],
),
),
);
}
我将第一个ClipRRect包裹在具有下一个ClipRRec的颜色(背景)的Container中,这样就达到了我想要的效果。我不确定这是否正确]
Container(
color: Colors.red,
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
child: Container(
height: 250.0,
margin: const EdgeInsets.only(
bottom: 6.0), //Same as `blurRadius` i guess
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(15),
bottomRight: Radius.circular(15)),
color: Colors.blue,
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(0.0, 1.0), //(x,y)
blurRadius: 6.0,
),
],
),
),
),
),
结果