gpt4 book ai didi

flutter - 如何在Flutter中编码矩形+椭圆形

转载 作者:行者123 更新时间:2023-12-03 04:34:07 34 4
gpt4 key购买 nike

Shape
我正在尝试在显示的图像中实现形状。我不知道该怎么做。我尝试的最后一件事是:

          Container(
height: 175,
decoration: BoxDecoration(
borderRadius: BorderRadius.vertical(
bottom: Radius.elliptical(175, 45),
),
),
)
如何创建此形状?

最佳答案

您可以使用自定义画家:

 class MyWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Container(
child: Container(
color: Colors.transparent,
height: 155,
width: 375,
child: CustomPaint(
painter: CurvePainter(),
),
),
);
}
}

class CurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = Color(0XFF382b47);
paint.style = PaintingStyle.fill;

var path = Path();

path.moveTo(0, size.height * 0.26);
path.quadraticBezierTo(
size.width / 2, size.height, size.width, size.height * 0.26);
path.lineTo(size.width, 0);
path.lineTo(0, 0);

canvas.drawPath(path, paint);
}

@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}

关于flutter - 如何在Flutter中编码矩形+椭圆形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64400390/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com