FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fluttercandies/dash_painter: a package for flutter canvas paint dash line path easily. · GitHub

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dash_painter

a package for flutter canvas paint dash line path easily.

1. DashPainter 如何使用

DashPainter 只负责对 路径 Path 的虚线化绘制,不承担组件职能。 一般用在拥有 Canvas 对象的回调方法中,比如自定义的 CustomPainter、Decoration。 具体使用案例见 demo

const DashPainter(span: 4, step: 9).paint(canvas, path, paint);

对于所有的路径都是使用的,如下的 圆角矩形 和 圆形;

圆角矩形 圆形

2. 点划线的使用

除了虚线,还可以绘制点划线 , pointCount 和 pointWidth两个属性,分别表示点划线数和点划线长。

const DashPainter(
    span: 4, // 空格长
    step: 10, // 实线长
    pointCount: 2, // 点划线个数
    pointWidth: 2 // 点划线长
).paint(canvas, path, paint);
  • 单点划线:

  • 双点划线:

  • 三点划线:


点画线圆:


DashPainter

可能很多人不会自定义画板自己绘制,或只想简单地使用。其实除了 CustomPainter 还有其他地方有 canvas。比如 Decoration 。 这里提供了 DashDecoration 的装饰,方便使用。如下实现一个渐变的单点画线圆角虚线框。

Container(
  width: 100,
  height: 100,
  decoration: DashDecoration(
      pointWidth: 2,
      step: 5,
      pointCount: 1,
      radius: Radius.circular(15),
      gradient: SweepGradient(colors: [
        Colors.blue,
        Colors.red,
        Colors.yellow,
        Colors.green
      ])),
  child: Icon(
    Icons.add,
    color: Colors.orangeAccent,
    size: 40,
  ),
),

About

a package for flutter canvas paint dash line path easily.

Resources

Stars

30 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL