zoukankan      html  css  js  c++  java
  • flutter canvas 简单绘画直线

    1. 定义一个class

    class MyPainter extends CustomPainter {
      Color lineColor;
      double width;
    
      MyPainter({this.lineColor, this.width});
      @override
      void paint(Canvas canvas, Size size) {
        Paint _paint = new Paint()
        ..color = Colors.blueAccent
        ..strokeCap = StrokeCap.round
        ..isAntiAlias = true
        ..strokeWidth = 5.0
        ..style = PaintingStyle.stroke;
        canvas.drawLine(Offset(20.0, 20.0), Offset(100.0, 100.0), _paint);
    
      }
    
      @override
      bool shouldRepaint(CustomPainter oldDelegate) => false;
    }

    2. 使用

    Container(
        child:CustomPaint(
            foregroundPainter: new MyPainter(
                 lineColor: Colors.lightBlueAccent,
                  8.0,
           ),
        ),
    ),
  • 相关阅读:
    mtu
    OC2_使用系统协议
    OC1_协议语句
    Json文件/网址解析
    文件归档
    Plist文件
    NS-Date/NSDateFormatter
    OC10_文件练习
    OC9_文件操作
    OC8_NSData
  • 原文地址:https://www.cnblogs.com/john-hwd/p/11202477.html
Copyright © 2011-2022 走看看