Created
January 18, 2021 21:25
-
-
Save murilinhoPs/e0d43b7a70efc6caa192f89405be9948 to your computer and use it in GitHub Desktop.
CustomProgressBar with Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class StepProgressBar extends StatelessWidget { | |
final int currentStep; | |
final int totalSteps; | |
final double leftPadding; | |
final double rightPadding; | |
final Color selectedColor; | |
final Color unselectedColor; | |
const StepProgressBar({ | |
Key key, | |
@required this.totalSteps, | |
@required this.currentStep, | |
this.leftPadding = 35.0, | |
this.rightPadding = 35.0, | |
this.selectedColor = const Color(0xff3873B8), | |
this.unselectedColor = Colors.black, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Padding( | |
padding: EdgeInsets.only( | |
top: 8, | |
left: leftPadding, | |
right: rightPadding, | |
bottom: 8, | |
), | |
child: Container( | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(40.0), | |
), | |
child: LinearProgressIndicator( | |
value: currentStep / totalSteps, | |
minHeight: 4, | |
valueColor: AlwaysStoppedAnimation<Color>(selectedColor), | |
backgroundColor: unselectedColor.withOpacity(0.2), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment