@@ -9,7 +9,7 @@ class DashedType extends CustomPainter {
99 this .strokeWidth = 2 ,
1010 this .dashedLine = const < double > [3 , 1 ],
1111 this .color = Colors .black,
12- this .type = GFBorderType .Rect ,
12+ this .type = GFBorderType .rect ,
1313 this .radius = const Radius .circular (0 ),
1414 this .customPath,
1515 }) : assert (dashedLine.isNotEmpty, 'dash line cannot be empty' );
@@ -21,7 +21,7 @@ class DashedType extends CustomPainter {
2121 final List <double > dashedLine;
2222
2323 /// color of type [Color] or GFColor which is used to change the color of the border type
24- final dynamic color;
24+ final Color color;
2525
2626 /// type of [GFBorderType] which is used to define the different types of borders ie, circle, Rect, RRect and oval
2727 final GFBorderType type;
@@ -56,20 +56,19 @@ class DashedType extends CustomPainter {
5656 Path _getPath (Size size) {
5757 Path path;
5858 switch (type) {
59- case GFBorderType .Circle :
59+ case GFBorderType .circle :
6060 path = _getCirclePath (size);
6161 break ;
62- case GFBorderType .RRect :
62+ case GFBorderType .rRect :
6363 path = _getRRectPath (size, radius);
6464 break ;
65- case GFBorderType .Rect :
65+ case GFBorderType .rect :
6666 path = _getRectPath (size);
6767 break ;
68- case GFBorderType .Oval :
68+ case GFBorderType .oval :
6969 path = _getOvalPath (size);
7070 break ;
7171 }
72-
7372 return dashPath (path, dashedarray: CircularIntervalList (dashedLine));
7473 }
7574
@@ -94,7 +93,6 @@ class DashedType extends CustomPainter {
9493 }
9594
9695 /// gives a Rounded Rectangular Path with [radius] of [size] for borderType
97-
9896 Path _getRRectPath (Size size, Radius radius) => Path ()
9997 ..addRRect (
10098 RRect .fromRectAndRadius (
@@ -140,10 +138,8 @@ class DashedType extends CustomPainter {
140138
141139class CircularIntervalList <T > {
142140 CircularIntervalList (this .values);
143-
144141 final List <T > values;
145142 int index = 0 ;
146-
147143 T get next {
148144 if (index >= values.length) {
149145 index = 0 ;
@@ -159,7 +155,6 @@ Path dashPath(Path source,
159155 if (source == null ) {
160156 return null ;
161157 }
162-
163158 final Path dest = Path ();
164159 for (final PathMetric metric in source.computeMetrics ()) {
165160 double distance = dashOffset._calculate (metric.length);
@@ -173,27 +168,26 @@ Path dashPath(Path source,
173168 draw = ! draw;
174169 }
175170 }
176-
177171 return dest;
178172}
179173
180174/// Specifies the starting position of a dashed array or line on a path, either as a percentage or absolute
181- enum _DashOffsetType { Absolute , Percentage }
175+ enum _DashOffsetType { absolute, percentage }
182176
183177class DashOffset {
184178 ///gives offset of the dashed path that will be measured as a percentage which ranges from 0.0 to 1.0
185179 DashOffset .percentage (double percentage)
186180 : _value = percentage.clamp (0.0 , 1.0 ) ?? 0.0 ,
187- _dashOffsetType = _DashOffsetType .Percentage ;
181+ _dashOffsetType = _DashOffsetType .percentage ;
188182
189183 ///gives offset of the dashed path that will be measured as a absolute value
190184 const DashOffset .absolute (double start)
191185 : _value = start ?? 0.0 ,
192- _dashOffsetType = _DashOffsetType .Absolute ;
186+ _dashOffsetType = _DashOffsetType .absolute ;
193187
194188 final double _value;
195189 final _DashOffsetType _dashOffsetType;
196190
197191 double _calculate (double length) =>
198- _dashOffsetType == _DashOffsetType .Absolute ? _value : length * _value;
192+ _dashOffsetType == _DashOffsetType .absolute ? _value : length * _value;
199193}
0 commit comments