如何创建内圆角框颤振
How to create Inner rounded Box Flutter
如何最简单地制作这样的盒子?
我尝试了很多 CustomPainter 和 Arcs 或 CustomClippers 但都失败了。我知道使用这些技术是可能的,但我无法做到。
(如果可能,请包括代码,我已经在这上面浪费了太多时间)
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Drawing Paths',
home: Container(
color: Colors.white,
child: CustomPaint(
painter: CurvePainter(),
),
),
);
}
}
class CurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = Colors.green[800];
paint.style = PaintingStyle.fill; // Change this to fill
Path path = Path();
path.moveTo(0, size.height * 0.5);
path.quadraticBezierTo(0, size.height * 0.2, 0, size.height * 0.1);
path.lineTo(size.width, size.height * 0.1);
path.lineTo(size.width, size.height * 0.5);
path.quadraticBezierTo(
size.width * 0.5, size.height * 0.25, 0, size.height * 0.5);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
如何最简单地制作这样的盒子?
我尝试了很多 CustomPainter 和 Arcs 或 CustomClippers 但都失败了。我知道使用这些技术是可能的,但我无法做到。 (如果可能,请包括代码,我已经在这上面浪费了太多时间)
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Drawing Paths',
home: Container(
color: Colors.white,
child: CustomPaint(
painter: CurvePainter(),
),
),
);
}
}
class CurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = Colors.green[800];
paint.style = PaintingStyle.fill; // Change this to fill
Path path = Path();
path.moveTo(0, size.height * 0.5);
path.quadraticBezierTo(0, size.height * 0.2, 0, size.height * 0.1);
path.lineTo(size.width, size.height * 0.1);
path.lineTo(size.width, size.height * 0.5);
path.quadraticBezierTo(
size.width * 0.5, size.height * 0.25, 0, size.height * 0.5);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}