Skip to content

Commit 0974913

Browse files
committed
formating code
1 parent ce0a026 commit 0974913

2 files changed

Lines changed: 20 additions & 72 deletions

File tree

lib/components/progress_indicator/gf_progress_indicator.dart

Lines changed: 6 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
22
import 'package:getflutter/types/gf_progress_type.dart';
33
import 'package:vector_math/vector_math_64.dart' as math;
44

5-
enum LinearStrokeCap { butt, round, roundAll }
6-
75
class GFProgressBar extends StatefulWidget {
86
///width of the Circular Progress bar
97
final double width;
@@ -28,7 +26,6 @@ class GFProgressBar extends StatefulWidget {
2826
///type of Widget which can be used in the first place before the progress bar
2927
final Widget leading;
3028

31-
3229
///type of Widget which can be used in the last place after the progress bar
3330
final Widget trailing;
3431

@@ -83,14 +80,8 @@ class GFProgressBar extends StatefulWidget {
8380
///type of double which should be from 0 to 1 to indicate the progress of the ProgressBars
8481
final double percentage;
8582

86-
final LinearStrokeCap linearStrokeCap;
87-
88-
89-
90-
9183
GFProgressBar({
9284
Key key,
93-
this.linearStrokeCap,
9485
this.percentage = 0.2,
9586
this.circleWidth = 5.0,
9687
this.circleStartAngle = 0.0,
@@ -112,7 +103,7 @@ class GFProgressBar extends StatefulWidget {
112103
this.fromRightToLeft = false,
113104
this.leading,
114105
this.trailing,
115-
this.padding = const EdgeInsets.symmetric(horizontal: 10.0),
106+
this.padding = const EdgeInsets.symmetric(horizontal: 10),
116107
this.alignment = MainAxisAlignment.start,
117108
this.clipLinearGradient = false,
118109
}) : super(key: key) {
@@ -124,7 +115,7 @@ class GFProgressBar extends StatefulWidget {
124115

125116
assert(circleStartAngle >= 0.0);
126117
if (percentage < 0.0 || percentage > 1.0) {
127-
throw Exception("Percent value must be a double between 0.0 and 1.0");
118+
throw Exception('Percent value must be a double between 0.0 and 1.0');
128119
}
129120
}
130121

@@ -256,7 +247,6 @@ class _GFProgressBarState extends State<GFProgressBar>
256247
linearGradient: widget.linearGradient,
257248
backgroundColor: widget.backgroundColor,
258249
circleWidth: widget.lineHeight,
259-
linearStrokeCap: widget.linearStrokeCap,
260250
mask: widget.mask,
261251
clipLinearGradient: widget.clipLinearGradient,
262252
),
@@ -301,11 +291,10 @@ class _GFProgressBarState extends State<GFProgressBar>
301291
)),
302292
)
303293
: Material(
304-
305294
child: Container(
306295
child: Column(
307-
mainAxisAlignment: MainAxisAlignment.center,
308-
mainAxisSize: MainAxisSize.min,
296+
crossAxisAlignment: CrossAxisAlignment.center,
297+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
309298
children: item,
310299
)),
311300
);
@@ -327,12 +316,10 @@ class LinearPainter extends CustomPainter {
327316
final LinearGradient linearGradient;
328317
final MaskFilter mask;
329318
final bool clipLinearGradient;
330-
GFProgressHeadType progressHeadType = GFProgressHeadType.circular;
331-
final LinearStrokeCap linearStrokeCap;
319+
GFProgressHeadType progressHeadType;
332320

333321
LinearPainter({
334322
this.circleWidth,
335-
this.linearStrokeCap = LinearStrokeCap.butt,
336323
this.progress,
337324
this.child,
338325
this.fromRightToLeft,
@@ -353,32 +340,12 @@ class LinearPainter extends CustomPainter {
353340
_paintLine.style = PaintingStyle.stroke;
354341
_paintLine.strokeWidth = circleWidth;
355342

356-
// if (progressHeadType == GFProgressHeadType.circular) {
357-
// _paintLine.strokeCap = StrokeCap.round;
358-
// } else if (progressHeadType == GFProgressHeadType.square) {
359-
// _paintLine.strokeCap = StrokeCap.square;
360-
// }
361-
362-
363-
if (linearStrokeCap == LinearStrokeCap.round) {
364-
_paintLine.strokeCap = StrokeCap.round;
365-
} else if (linearStrokeCap == LinearStrokeCap.butt) {
366-
_paintLine.strokeCap = StrokeCap.butt;
367-
} else {
368-
_paintLine.strokeCap = StrokeCap.round;
369-
_paintBackground.strokeCap = StrokeCap.round;
370-
}
371-
372-
373-
if (progressHeadType == GFProgressHeadType.circular) {
374-
_paintLine.strokeCap = StrokeCap.round;
375-
} else if (progressHeadType == GFProgressHeadType.square) {
343+
if (progressHeadType == GFProgressHeadType.square) {
376344
_paintLine.strokeCap = StrokeCap.square;
377345
} else {
378346
_paintLine.strokeCap = StrokeCap.round;
379347
_paintBackground.strokeCap = StrokeCap.round;
380348
}
381-
382349
}
383350

384351
@override
@@ -438,7 +405,6 @@ class LinearPainter extends CustomPainter {
438405
class CirclePainter extends CustomPainter {
439406
final Paint _paintBackground = Paint();
440407
final Paint _paintLine = Paint();
441-
final Paint _paintBackgroundStartAngle = Paint();
442408
final double circleWidth;
443409
final double progress;
444410
final double radius;
@@ -475,8 +441,6 @@ class CirclePainter extends CustomPainter {
475441
} else if (progressHeadType == GFProgressHeadType.square) {
476442
_paintLine.strokeCap = StrokeCap.square;
477443
}
478-
479-
480444
}
481445

482446
@override
@@ -500,16 +464,6 @@ class CirclePainter extends CustomPainter {
500464

501465
double circleStartAngleFixedMargin = 1.0;
502466

503-
// if (arcBackgroundColor != null) {
504-
// canvas.drawArc(
505-
// Rect.fromCircle(center: child, radius: radius),
506-
// math.radians(-90.0 + fixedStartAngle),
507-
// math.radians(360 * circleStartAngleFixedMargin),
508-
// false,
509-
// _paintBackgroundStartAngle,
510-
// );
511-
// }
512-
513467
if (reverse) {
514468
final start = math
515469
.radians(360 * circleStartAngleFixedMargin - 90.0 + fixedStartAngle);

lib/components/progress_indicator/progress_bar.dart

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import 'package:getflutter/types/gf_progress_type.dart';
33
import 'package:getflutter/getflutter.dart';
44

55
class ProgressBarDemo extends StatefulWidget {
6-
const ProgressBarDemo ({Key key,
7-
this.width,
8-
this.type= GFProgressType.round
9-
}):super(key:key);
6+
const ProgressBarDemo({Key key, this.width, this.type = GFProgressType.round})
7+
: super(key: key);
108

11-
12-
final GFProgressType type ;
9+
final GFProgressType type;
1310
final double width;
1411

1512
@override
@@ -18,21 +15,18 @@ class ProgressBarDemo extends StatefulWidget {
1815

1916
class _ProgressBarDemoState extends State<ProgressBarDemo> {
2017
@override
21-
Widget build(BuildContext context) {
22-
return Container(
23-
alignment: Alignment.center,
24-
width: widget.type == GFProgressType.linear? MediaQuery.of(context).size.width: widget.width ,
25-
height: widget.type == GFProgressType.round?50: 20,
26-
27-
decoration: BoxDecoration(
18+
Widget build(BuildContext context) => Container(
19+
alignment: Alignment.center,
20+
width: widget.type == GFProgressType.linear
21+
? MediaQuery.of(context).size.width
22+
: widget.width,
23+
height: widget.type == GFProgressType.round ? 50 : 20,
24+
decoration: BoxDecoration(
2825
// color: Colors.orange,
29-
border: Border.all(color: Colors.orange, width: 3),
26+
border: Border.all(color: Colors.orange, width: 3),
3027
//shape: BoxShape.rectangle
3128
// shape: widget.type == GFProgressType.round?BoxShape.circle?? widget.type==GFProgressType.square:BoxShape.rectangle
32-
),
33-
34-
child: Text('75%'),
35-
36-
);
37-
}
29+
),
30+
child: const Text('75%'),
31+
);
3832
}

0 commit comments

Comments
 (0)