如何在这些弯曲的Flutter 中这样做

enter image description here

我是新手,我想学习如何做这样的事情,我试着用Stack来做,但它没有像图片那样显示出来!

我想学习如何在设计中做曲线! 请帮帮我!

推荐答案

使用‘Flutter 形状生成器’创建自定义绘制形状(节省大量时间,但需要登录才能复制代码).使用堆栈将圆形图像放在上面.

我使用的工具:https://fluttershapemaker.com/

使用自定义绘画小工具

    child: CustomPaint(
       size: Size(WIDTH,(WIDTH*0.625).toDouble()), //You can Replace [WIDTH] with your desired width for Custom Paint and height will be calculated automatically
       painter: RPSCustomPainter(),
    ),

自定义油漆代码

class RPSCustomPainter extends CustomPainter{
  
  @override
  void paint(Canvas canvas, Size size) {
    
    

  Paint paint_0 = new Paint()
      ..color = Color.fromARGB(255, 252, 107, 107)
      ..style = PaintingStyle.fill
      ..strokeWidth = 1.0;
     
         
    Path path_0 = Path();
    path_0.moveTo(0,size.height*0.5000000);
    path_0.quadraticBezierTo(size.width*0.0631250,size.height*0.5000000,size.width*0.0625000,size.height*0.4400000);
    path_0.cubicTo(size.width*0.0625000,size.height*0.1400000,size.width*0.3137500,size.height*0.1410000,size.width*0.3125000,size.height*0.4400000);
    path_0.quadraticBezierTo(size.width*0.3131250,size.height*0.5000000,size.width*0.3750000,size.height*0.5000000);
    path_0.lineTo(size.width,size.height*0.5000000);
    path_0.lineTo(size.width,size.height);
    path_0.lineTo(0,size.height);

    canvas.drawPath(path_0, paint_0);
  
    
  }

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

根据您的需要调整值

Shape will look like this

Flutter相关问答推荐

flutter:如何将字体大小设置得更大(更大)

自动测试Flutter应用程序进行QA的最佳方法是什么?

build_runner显示错误没有为类ClassDeclaration定义getter宏关键字'

如何在2024年使用Ffltter将用户数据保存在云FireStore中?

为什么要在值列表中两次放入空安全性

从外部类动态更改IconButton的图标

如何使文本表格域在抖动中变圆?

任务';:app:check DebugDuplicateClasss';的Ffltter Share_plus抛出执行失败

Flutter 数独网格

不要跨同步间隔使用BuildContext

如何从flutter连接PostgreSQL数据库?

为什么我们需要使用ChangeNotifierProvider而不是仅仅使用ChangeNotifier?

更改 flutter listview 中的布局

如何更改 DropDownMenu 的显示方向?

忽略异步函数上的 context.mounted 访问 linting 错误是否安全?

Flutter - 根据从第一个 DropdownButtonForm 中 Select 的内容在第二个 DropdownButton 上显示选项

Flutter Firestore 数据库排序最近 24 小时内最喜欢的文档

Flutter Web Responsiveness 效率不高

既然我们已经有了 Flutter 的内置 setState,为什么还要在 Flutter 中使用 BloC 或 Provider?

我想将我的模型类对象发送到下一个屏幕之前我这样做首先我在第二个屏幕中声明对象