[英]is it Posible Create This UI in FLUTTER?
I want make Container like this in Flutter for my Application, is is posbile through some tweaks in boxdecoration without using any packages?我想在 Flutter 中为我的应用程序制作这样的容器,是否可以在不使用任何包的情况下通过对 boxdecoration 进行一些调整来实现? The sides of this view should be like that, something like a paper torn from a book.
这个视图的侧面应该是那样的,就像从书上撕下来的纸一样。
We can use CustomClipper
for this.我们可以为此使用
CustomClipper
。
class CuponClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
path
..lineTo(0, size.height)
..lineTo(size.width, size.height)
..lineTo(size.width, 0)
..lineTo(0, 0);
final radius = size.height * .065;
Path holePath = Path();
for (int i = 1; i <= 4; i++) {
holePath.addOval(
Rect.fromCircle(
center: Offset(0, (size.height * .2) * i),
radius: radius,
),
);
}
for (int i = 1; i <= 4; i++) {
holePath.addOval(
Rect.fromCircle(
center: Offset(size.width, (size.height * .2) * i),
radius: radius,
),
);
}
return Path.combine(PathOperation.difference, path, holePath);
}
@override
bool shouldReclip(covariant CustomClipper<Path> oldClipper) => false;
}
And use并使用
body: Center(
child: ClipPath(
clipper: CuponClipper(),
child: Container(
height: 100,
width: 400,
alignment: Alignment.center,
color: Colors.amber,
child: Text("sdsdsd"),
),
),
),
You can use this library: https://pub.dev/packages/coupon_uikit你可以使用这个库: https://pub.dev/packages/coupon_uikit
If you want to create own widget you must search CustomClippers .如果你想创建自己的小部件,你必须搜索CustomClippers 。 For example you can take a look this code:
例如你可以看看这段代码:
https://github.com/lohanidamodar/flutter_custom_clippers/blob/master/lib/src/movie_ticket_both_side_clipper.dart https://github.com/lohanidamodar/flutter_custom_clippers/blob/master/lib/src/movie_ticket_both_side_clipper.dart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.