flutter - 颤振 - 朝下画弧
问题描述
我需要画这样的东西:
我尝试通过创建 aCustomClipper<Path>
并在 a 中使用它来做到这一点ClipPath()
这是我的代码:
class ArcBackground extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipPath(
child: Container(
width: double.infinity,
height: 400.0,
color: Colors.orange,
),
clipper: RoundedClipper(),
);
}
}
class RoundedClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height);
path.quadraticBezierTo(
size.width / 2,
size.height - 100,
size.width,
size.height
);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
这段代码给了我以下输出:
正如您所看到的,因为我将quadraticaBezierTo()
y1
属性设置为 ,所以圆弧指向上方size.height - 100
,我原以为我可以通过设置y1
属性来让圆弧指向下方,size.height + 100
但它不起作用。
如何实现向下指向的弧?
解决方案
这对你有用吗?
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height-100);
path.quadraticBezierTo(
size.width / 2,
size.height,
size.width,
size.height - 100
);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
推荐阅读
- amazon-web-services - AWS S3 File Copy - monitor when a file doesn't get moved into S3 Bucket
- url - mc_eid showing [UNIQID] in MailChimp link after enabling tracking
- java - 如何在 adnroid 中获取 recyclerView 项目的 X 和 Y 坐标?
- android-fragments - 带有 RecyclerView 滚动问题的垂直 ViewPager2
- android - Android : Branch SDK Api Error after changed date on device
- python - fuzzywuzzy match in python with if condition
- python - 使用小部件在 jupyter notebook 中显示 gif
- php - bootstrap 4 折叠打开同一张卡
- ios - Firebase user merge Apple account into existing one
- reactjs - Passing functions to props.children