Skip to content

Instantly share code, notes, and snippets.

@samuelematias
Created August 20, 2020 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelematias/edf260ec230b83bdb4acf18fa7aabbf9 to your computer and use it in GitHub Desktop.
Save samuelematias/edf260ec230b83bdb4acf18fa7aabbf9 to your computer and use it in GitHub Desktop.
Line Progress Animated.
import 'package:flutter/material.dart';
class AnimatedLineProgress extends StatelessWidget {
final double minLineWidth;
final double maxLineWidth;
final double minLineHeight;
final double maxLineHeight;
final Color lineColor;
final double progressValue;
final Color progressColor;
final int animatedProgressDuration;
const AnimatedLineProgress({
Key key,
this.minLineWidth = 0,
this.maxLineWidth,
this.minLineHeight = 4,
this.maxLineHeight = 4,
this.lineColor = Colors.grey,
@required this.progressValue,
this.progressColor = Colors.green,
this.animatedProgressDuration = 2,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final double _maxLineWidth =
maxLineWidth ?? MediaQuery.of(context).size.width * 0.6;
final double _progressValue = progressValue / 10;
return Column(
children: [
Stack(
children: [
AnimatedContainer(
constraints: BoxConstraints(
minWidth: minLineWidth,
maxWidth: _maxLineWidth,
minHeight: minLineHeight,
maxHeight: maxLineHeight,
),
decoration: BoxDecoration(
color: lineColor,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
duration: Duration(seconds: animatedProgressDuration),
height: maxLineHeight,
),
AnimatedContainer(
constraints: BoxConstraints(
minWidth: minLineWidth,
maxWidth: _maxLineWidth,
),
decoration: BoxDecoration(
color: progressColor,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
),
duration: Duration(seconds: animatedProgressDuration),
width: _progressValue,
height: maxLineHeight,
),
],
)
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment