@@ -3,14 +3,6 @@ import 'package:flutter/material.dart';
33import 'package:getflutter/types/gf_progress_type.dart' ;
44import 'package:vector_math/vector_math_64.dart' as math;
55
6- enum LinearBarType { butt, round, roundAll , circular}
7-
8- enum CircularBarType { butt, round, square }
9-
10- enum ArcType {
11- HALF ,
12- FULL ,
13- }
146
157class GFProgressBar extends StatefulWidget {
168
@@ -48,8 +40,6 @@ class GFProgressBar extends StatefulWidget {
4840 ///type of Widget which is used to identity the percentage of progress complete
4941 final Widget child;
5042
51- ///the types of linear progress bar which will be reflected on the edges and of types, butt, round, roundAll
52- final LinearBarType linearBarType;
5343
5444 ///type of MainAxisAlignment used to align the leading, trailing and the progress bar in a fashion
5545 final MainAxisAlignment alignment;
@@ -82,20 +72,16 @@ class GFProgressBar extends StatefulWidget {
8272 ///type of [GFProgressType] which changes the shape of progress bar based on the type ie, circle and linear
8373 final GFProgressType type ;
8474
75+
76+ final GFProgressHeadType progressHeadType;
77+
8578 ///type of double which defines the width of the Circle in CircularProgressBar
8679 final double circleWidth;
8780
88- ///the types of Circular progress bar which will be reflected on the arcs and of types, butt, round, roundAll
89- final CircularBarType circularBarType;
9081
9182 ///type of double in which the angle on the circle starts to progress (in degrees, eg: 0.0, 45.0, 90.0)
9283 final double circleStartAngle;
9384
94- ///type of ArcType which defines different types arcs in Circular Progress Bar ie, round and square
95- final ArcType arcType;
96-
97- ///type of [Color] or [GFColor] used to set background color of the arc in CircularProgress Bar
98- final dynamic arcBackgroundColor;
9985
10086 ///type of bool used to display the progress in reverse mode
10187 final bool reverse;
@@ -121,19 +107,16 @@ class GFProgressBar extends StatefulWidget {
121107 this .animationDuration = 500 ,
122108 this .child,
123109 this .autoAlive = true ,
124- this .circularBarType,
125- this .arcBackgroundColor,
126- this .arcType,
127110 this .animateFromLastPercentage = false ,
128111 this .reverse = false ,
129112 this .mask,
130113 this .type,
114+ this .progressHeadType,
131115 this .lineHeight = 5.0 ,
132116 this .width,
133117 this .fromRightToLeft = false ,
134118 this .leading,
135119 this .trailing,
136- this .linearBarType,
137120 this .padding = const EdgeInsets .symmetric (horizontal: 10.0 ),
138121 this .alignment = MainAxisAlignment .start,
139122 this .clipLinearGradient = false ,
@@ -150,9 +133,6 @@ class GFProgressBar extends StatefulWidget {
150133 throw Exception ("Percent value must be a double between 0.0 and 1.0" );
151134 }
152135
153- if (arcType == null && arcBackgroundColor != null ) {
154- throw ArgumentError ('arcType is required when you arcBackgroundColor' );
155- }
156136 }
157137
158138 @override
@@ -278,19 +258,19 @@ _updateProgress() {
278258 var containerWidget = Container (
279259 width: hasSetWidth ? widget.width : double .infinity,
280260 decoration: BoxDecoration (
281- shape: widget.type == GFProgressType .round? BoxShape .circle?? widget.type== GFProgressType .square: BoxShape .rectangle
261+ // shape: widget.type == GFProgressType.round?BoxShape.circle?? widget.type==GFProgressType.square:BoxShape.rectangle
282262 ),
283263 height: widget.lineHeight,
284264 padding: widget.padding,
285265 child: widget.type== GFProgressType .linear? CustomPaint (
286266 painter: LinearPainter (
267+ progressHeadType: widget.progressHeadType,
287268 fromRightToLeft: widget.fromRightToLeft,
288269 progress: _progressPercent,
289270 child: widget.child,
290271 progressBarColor: widget.progressBarColor,
291272 linearGradient: widget.linearGradient,
292273 backgroundColor: widget.backgroundColor,
293- linearBarType: widget.linearBarType,
294274 circleWidth: widget.lineHeight,
295275 mask: widget.mask,
296276 clipLinearGradient: widget.clipLinearGradient,
@@ -301,15 +281,13 @@ _updateProgress() {
301281 : Container (),
302282 ): CustomPaint (
303283 painter: CirclePainter (
284+ progressHeadType: widget.progressHeadType,
304285 progress: _percentage * 360 ,
305286 progressBarColor: widget.progressBarColor,
306287 backgroundColor: widget.backgroundColor,
307288 circleStartAngle: widget.circleStartAngle,
308- circularBarType: widget.circularBarType,
309289 radius: (widget.radius / 2 ) - widget.circleWidth / 2 ,
310290 circleWidth: widget.circleWidth,
311- arcBackgroundColor: widget.arcBackgroundColor,
312- arcType: widget.arcType,
313291 reverse: widget.reverse,
314292 linearGradient: widget.linearGradient,
315293 mask: widget.mask),
@@ -365,10 +343,10 @@ class LinearPainter extends CustomPainter {
365343 final fromRightToLeft;
366344 final Color progressBarColor;
367345 final Color backgroundColor;
368- final LinearBarType linearBarType;
369346 final LinearGradient linearGradient;
370347 final MaskFilter mask;
371348 final bool clipLinearGradient;
349+ final GFProgressHeadType progressHeadType;
372350
373351 LinearPainter ({
374352 this .circleWidth,
@@ -377,7 +355,7 @@ class LinearPainter extends CustomPainter {
377355 this .fromRightToLeft,
378356 this .progressBarColor,
379357 this .backgroundColor,
380- this .linearBarType = LinearBarType .butt ,
358+ this .progressHeadType ,
381359 this .linearGradient,
382360 this .mask,
383361 this .clipLinearGradient,
@@ -392,13 +370,10 @@ class LinearPainter extends CustomPainter {
392370 _paintLine.style = PaintingStyle .stroke;
393371 _paintLine.strokeWidth = circleWidth;
394372
395- if (linearBarType == LinearBarType .round ) {
373+ if (progressHeadType == GFProgressHeadType .circular ) {
396374 _paintLine.strokeCap = StrokeCap .round;
397- } else if (linearBarType == LinearBarType .butt) {
398- _paintLine.strokeCap = StrokeCap .butt;
399- } else {
400- _paintLine.strokeCap = StrokeCap .round;
401- _paintBackground.strokeCap = StrokeCap .round;
375+ } else if (progressHeadType == GFProgressHeadType .square) {
376+ _paintLine.strokeCap = StrokeCap .square;
402377 }
403378 }
404379
@@ -467,26 +442,24 @@ class CirclePainter extends CustomPainter {
467442 final double radius;
468443 final Color progressBarColor;
469444 final Color backgroundColor;
470- final CircularBarType circularBarType;
471445 final double circleStartAngle;
472446 final LinearGradient linearGradient;
473447 final Color arcBackgroundColor;
474- final ArcType arcType;
475448 final bool reverse;
476449 final MaskFilter mask;
450+ final GFProgressHeadType progressHeadType;
477451
478452 CirclePainter (
479453 {this .circleWidth,
480454 this .progress,
481455 @required this .radius,
456+ this .progressHeadType,
482457 this .progressBarColor,
483458 this .backgroundColor,
484459 this .circleStartAngle = 0.0 ,
485- this .circularBarType = CircularBarType .round,
486460 this .linearGradient,
487461 this .reverse,
488462 this .arcBackgroundColor,
489- this .arcType,
490463 this .mask}) {
491464 _paintBackground.color = backgroundColor;
492465 _paintBackground.style = PaintingStyle .stroke;
@@ -501,11 +474,9 @@ class CirclePainter extends CustomPainter {
501474 _paintLine.color = progressBarColor;
502475 _paintLine.style = PaintingStyle .stroke;
503476 _paintLine.strokeWidth = circleWidth;
504- if (circularBarType == CircularBarType .round ) {
477+ if (progressHeadType == GFProgressHeadType .circular ) {
505478 _paintLine.strokeCap = StrokeCap .round;
506- } else if (circularBarType == CircularBarType .butt) {
507- _paintLine.strokeCap = StrokeCap .butt;
508- } else {
479+ } else if (progressHeadType == GFProgressHeadType .square) {
509480 _paintLine.strokeCap = StrokeCap .square;
510481 }
511482 }
@@ -530,15 +501,7 @@ class CirclePainter extends CustomPainter {
530501 double fixedStartAngle = circleStartAngle;
531502
532503 double circleStartAngleFixedMargin = 1.0 ;
533- if (arcType != null ) {
534- if (arcType == ArcType .FULL ) {
535- fixedStartAngle = 220 ;
536- circleStartAngleFixedMargin = 172 / fixedStartAngle;
537- } else {
538- fixedStartAngle = 270 ;
539- circleStartAngleFixedMargin = 135 / fixedStartAngle;
540- }
541- }
504+
542505
543506 if (arcBackgroundColor != null ) {
544507 canvas.drawArc (
0 commit comments