Flutter 如何在颤振中创建没有间距的半圆
我想在底部创建一个半圆。但是有一些空间我不能删除。 //飘动Flutter 如何在颤振中创建没有间距的半圆,flutter,Flutter,我想在底部创建一个半圆。但是有一些空间我不能删除。 //飘动 为什么不走捷径呢 像这样的 容器( 身高:30, 宽度:50, 颜色:颜色。透明, 子容器:新容器( 装饰:新盒子装饰( 颜色:颜色,黑色, borderRadius:仅限新的borderRadius( 左上角:常数半径。圆形(40.0), 右上角:常数半径。圆形(40.0), ), ), ), ), 您可以使用ArcView轻松实现此视图。见附图 @override Widget build(BuildContext co
为什么不走捷径呢
像这样的
容器(
身高:30,
宽度:50,
颜色:颜色。透明,
子容器:新容器(
装饰:新盒子装饰(
颜色:颜色,黑色,
borderRadius:仅限新的borderRadius(
左上角:常数半径。圆形(40.0),
右上角:常数半径。圆形(40.0),
),
),
),
),
您可以使用ArcView轻松实现此视图。见附图
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Row(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Arc(
arcType: ArcType.CONVEX,
edge: Edge.TOP,
height: 70.0,
clipShadows: [ClipShadow(color: Colors.black)],
child: new Container(
height: 70,
width: MediaQuery.of(context).size.width,
color: Colors.lime,
),
),
),
],
),
),
);
}
简单的解决方案,谢谢。很高兴它有帮助,欢迎您。。
@override
Widget build(BuildContext context) {
return Container(
child: Center(
child: Row(
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: Arc(
arcType: ArcType.CONVEX,
edge: Edge.TOP,
height: 70.0,
clipShadows: [ClipShadow(color: Colors.black)],
child: new Container(
height: 70,
width: MediaQuery.of(context).size.width,
color: Colors.lime,
),
),
),
],
),
),
);
}
class CustomHalfCircleClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final Path path = new Path();
path.lineTo(0.0, size.height / 2);
path.lineTo(size.width, size.height / 2);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}
new ClipPath(
clipper: new CustomHalfCircleClipper(),
child: new Container(
height: MediaQuery.of(context).size.width,
width: MediaQuery.of(context).size.width,
decoration: new BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(
MediaQuery.of(context).size.width / 2),
),
),
)