簡體   English   中英

如何創建內圓框 Flutter

[英]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;
}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM