如图所示,实现带弧度的容器,用

CustomPaint实现,直接上代码
import 'dart:math';import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';void main() {runApp(MyApp());
}class MyApp extends StatelessWidget {// This widget is the root of your application.@overrideWidget build(BuildContext context) {return MaterialApp(title: 'Flutter Demo',theme: ThemeData(// This is the theme of your application.//// Try running your application with "flutter run". You'll see the// application has a blue toolbar. Then, without quitting the app, try// changing the primarySwatch below to Colors.green and then invoke// "hot reload" (press "r" in the console where you ran "flutter run",// or simply save your changes to "hot reload" in a Flutter IDE).// Notice that the counter didn't reset back to zero; the application// is not restarted.primarySwatch: Colors.blue,// This makes the visual density adapt to the platform that you run// the app on. For desktop platforms, the controls will be smaller and// closer together (more dense) than on mobile platforms.visualDensity: VisualDensity.adaptivePlatformDensity,),home: MyHomePage(title: 'Flutter Demo Home Page'),);}
}class MyHomePage extends StatefulWidget {MyHomePage({Key key, this.title}) : super(key: key);// This widget is the home page of your application. It is stateful, meaning// that it has a State object (defined below) that contains fields that affect// how it looks.// This class is the configuration for the state. It holds the values (in this// case the title) provided by the parent (in this case the App widget) and// used by the build method of the State. Fields in a Widget subclass are// always marked "final".final String title;@override_MyHomePageState createState() => _MyHomePageState();
}class _MyHomePageState extends State<MyHomePage> {int _counter = 0;void _incrementCounter() {setState(() {// This call to setState tells the Flutter framework that something has// changed in this State, which causes it to rerun the build method below// so that the display can reflect the updated values. If we changed// _counter without calling setState(), then the build method would not be// called again, and so nothing would appear to happen._counter++;});}@overrideWidget build(BuildContext context) {// This method is rerun every time setState is called, for instance as done// by the _incrementCounter method above.//// The Flutter framework has been optimized to make rerunning build methods// fast, so that you can just rebuild anything that needs updating rather// than having to individually change instances of widgets.return Scaffold(appBar: AppBar(// Here we take the value from the MyHomePage object that was created by// the App.build method, and use it to set our appbar title.title: Text(widget.title),),body: Center(// Center is a layout widget. It takes a single child and positions it// in the middle of the parent.child: Column(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Text('You have pushed the button this many times:',),Text('$_counter',style: Theme.of(context).textTheme.headline4,),Container(height: 100,color: Colors.red,child: CustomPaint(painter: Sky(),child: Center(child: Text('',style: const TextStyle(fontSize: 40.0,fontWeight: FontWeight.w900,color: Color(0xFFFFFFFF),),),),))],),),floatingActionButton: FloatingActionButton(onPressed: _incrementCounter,tooltip: 'Increment',child: Icon(Icons.add),), // This trailing comma makes auto-formatting nicer for build methods.);}
}class Sky extends CustomPainter {Paint _paint = Paint()..color = Colors.red //画笔颜色..strokeCap = StrokeCap.butt //画笔笔触类型// ..isAntiAlias = true //是否启动抗锯齿// ..blendMode = BlendMode.exclusion //颜色混合模式..style = PaintingStyle.fill //绘画风格,默认为填充// ..colorFilter = ColorFilter.mode(Colors.redAccent,//     BlendMode.exclusion) //颜色渲染模式,一般是矩阵效果来改变的,但是flutter中只能使用颜色混合模式// ..maskFilter = MaskFilter.blur(BlurStyle.inner, 3.0) //模糊遮罩效果,flutter中只有这个..filterQuality = FilterQuality.high //颜色渲染模式的质量..strokeWidth = 1.0; //@overridevoid paint(Canvas canvas, Size size) {// Path path = new Path();// path.moveTo(0, 0);// path.lineTo(100, 100);// path.lineTo(200, 200);// path.lineTo(0, 0);// path.close();// canvas.drawPath(path, _paint);// canvas.drawCircle(Offset(100, 100), 50, _paint);canvas.drawLine(Offset(20.0, 20.0), Offset(100.0, 100.0), _paint);const PI = 3.1415926;// Rect rect2 = Rect.fromCircle(center: Offset(100.0, 50.0), radius: 200.0);// canvas.drawArc(rect2, -PI, PI, false, _paint,);// Rect rect1 = Rect.fromPoints(Offset(150.0, 200.0), Offset(300.0, 250.0));// canvas.drawOval(rect1, _paint);var startPoint = Offset(0, size.height); 开始位置var controlPoint1 = Offset(size.width / 4, size.height / 3 * 4); 控制点var controlPoint2 = Offset(3 * size.width / 4, size.height / 3 * 4);控制点var endPoint = Offset(size.width, size.height);结束位置var path = Path();path.moveTo(startPoint.dx, startPoint.dy);path.cubicTo(controlPoint1.dx, controlPoint1.dy,controlPoint2.dx, controlPoint2.dy,endPoint.dx, endPoint.dy);canvas.drawPath(path, _paint);}@overridebool shouldRepaint(Sky oldDelegate) => false;@overridebool shouldRebuildSemantics(Sky oldDelegate) => false;
}

Flutter绘制弧线相关推荐

  1. html绘制圆形和弧形的代码,通过HTML5 Canvas API绘制弧线和圆形的教程

    在html5中,CanvasRenderingContext2D对象也提供了专门用于绘制圆形或弧线的方法,请参考以下属性和方法介绍: JavaScript Code复制内容到剪贴板 arc(x, y, ...

  2. flash 绘图API:绘制弧线

    把之前没有记录的笔记都记录一下,顺便方便日后查询.绘制弧线,对于一些制作课件的人来讲会有一些用处的.绘制弧线采用的基本思路是采用描点的方法实现.从一个开始角度,到另一个角度结束,在这个角度区间里面进行 ...

  3. indesign如何画弧线_钢笔工具怎么绘制弧线?AI钢笔工具用法全解

    ai中的钢笔工具是我们经常需要用到的,并且也是一个重要的难点,尤其对于新手来说,更不知道怎么操作,那么钢笔工具怎么绘制弧线?下面小编就为大家介绍AI钢笔工具用法,希望对学习钢笔工具的朋友有所帮助. 下 ...

  4. Flutter 绘制Paint

    Flutter 的绘制主要涉及两个Widget: CustomPainter, CustomPaint CustomPainter:提供画布的组件: 有几个主要的参数: a. painter : 绘制 ...

  5. Flutter绘制虚线的方法

    Flutter 自带的 Canvas 并没有 Android 中的 Canvas 那么强大,连虚线都不支持. 今天周日,下午抽时间写了两个 Canvas 扩展函数,实现了绘制虚线线段和虚线矩形. 效果 ...

  6. pygame绘制弧线

    pygame中绘制弧线的函数如下: pygame.draw.arc(surface, color, rect, start_angle, stop_angle, width) 需要传入的参数: sur ...

  7. html五绘制弧线的方法是,使用HTML5 Canvas API绘制弧线的教程

    绘制标准圆弧 在开始之前,我们优化一下我们的作图环境.灵感来自于上节课的纹理,如果不喜欢这个背景,我在images目录下还提供了其他的背景图,供大家选择.另外把所有的样式表都写在了 下.JavaScr ...

  8. Flutter绘制指南06-颜色的基本操作

    本节目标 [1]. 认识Dart中的颜色表示方式 [2]. 了解颜色,[混合模式]的坐拥1 [3]. 了解如何读取图片中的像素颜色 一. 认识颜色 Color类在dart.ui包下,在Dart里面,颜 ...

  9. 使用matlab绘制弧线,MATLAB求解叶型中弧线

    MATLAB求解叶型中弧线 MATLAB求解叶型中弧线 对于从事流体力学及相关行业的科研人员来说,中弧线这一名词一定耳熟能详,在日常的科研工作中可能会存在着求解某一特定叶型中弧线的需求.本文就简单介绍 ...

最新文章

  1. 使用pinctrl 和 gpio 子系统的字符设备驱动
  2. 3.5 向量化实现的解释-深度学习-Stanford吴恩达教授
  3. 九、oracle 事务
  4. HDU2031 进制转换【进制】
  5. 一个REST风格的URI设计方案[Blog Web Services]
  6. 【PostgreSQL-9.6.3】进程及体系结构
  7. 2021-05-06 git 设置XX门8580端口代理访问github
  8. 过来人谈谈计算机考研复试
  9. 通俗易懂的Monte Carlo积分方法(一)
  10. 手机mtkcdc端口如何开启_MTK驱动安装教程(手机黑屏刷机)
  11. Git三大特色之Stage(暂存区)--留着当资料
  12. 关于异常结存的问题,库存结存为什么会产生数量为0,成本不为0的异常情况
  13. oracle to_char 进制转换_〖Oracle 转载〗Oracle的数据类型转换 to_char
  14. BIM为绿色建筑提供数据技术支持,Revit软件及插件提供BIM效率
  15. ASP WebShell 后门脚本与免杀
  16. mac 重置mysql root密码_Mac下忘记Mysql root密码重置
  17. 英特尔卖了通信与手机处理器,中国厂商是哭还是笑?
  18. Matplotlib contours 等高线图
  19. oracle erp日志,错误,什么地方看日志
  20. 程序员的阿里命---一个总想馋着你的阿里巴巴

热门文章

  1. 计算机基础—硬件之主板与芯片组
  2. 利用U盘安装Ubuntu后U盘的恢复
  3. Python自制随机食物生成器(食物可自拟)
  4. 领导让你做超出本职岗位的工作,欣然接受or 坚决拒绝?
  5. 微积分提纲+公式整理(大一下)
  6. wxWidgets的体系结构
  7. PageHelper 分页插件
  8. 因个人职业发展原因 优信CMO王鑫发内部信宣布辞职
  9. java+mysql 基于ssm的网上甜品店系统
  10. 数组写入listview