9、Flutter Widget - CustomPaint;

Melrose發表於2019-03-05

  使用Flutter也可以訪問低階別的繪畫呼叫。

自定義Painter ;

class MyPainter extends CustomPainter{
  @override
   void paint(Canvas canvas,Size size){
    canvas.drawLine(); 
    ...
  }

  @override
  bool shouldRepaint(CustomPainter old){
  return old.myParameter !=myParameter;
}
 
}
複製程式碼

將Painter新增到CustomPaint小部件中;

CustomPaint(
    size:Size(200,100),
    painter:MyPainter(),
)
複製程式碼

相關文章