LinearProgressBar constructor
LinearProgressBar({
- Key? key,
- Color fillColor = Colors.transparent,
- double percent = 0.0,
- double lineHeight = 5.0,
- double? width,
- Color? backgroundColor,
- LinearGradient? linearGradientBackgroundColor,
- LinearGradient? linearGradient,
- Color? progressColor,
- bool animation = false,
- int animationDuration = 500,
- bool animateFromLastPercent = false,
- bool isRTL = false,
- Widget? leading,
- Widget? trailing,
- Widget? center,
- bool addAutomaticKeepAlive = true,
- Radius? barRadius,
- EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 10.0),
- MainAxisAlignment alignment = MainAxisAlignment.start,
- MaskFilter? maskFilter,
- bool clipLinearGradient = false,
- Curve curve = Curves.linear,
- bool restartAnimation = false,
- VoidCallback? onAnimationEnd,
- Widget? widgetIndicator,
- Color? progressBorderColor,
Implementation
LinearProgressBar({
Key? key,
this.fillColor = Colors.transparent,
this.percent = 0.0,
this.lineHeight = 5.0,
this.width,
Color? backgroundColor,
this.linearGradientBackgroundColor,
this.linearGradient,
Color? progressColor,
this.animation = false,
this.animationDuration = 500,
this.animateFromLastPercent = false,
this.isRTL = false,
this.leading,
this.trailing,
this.center,
this.addAutomaticKeepAlive = true,
this.barRadius,
this.padding = const EdgeInsets.symmetric(horizontal: 10.0),
this.alignment = MainAxisAlignment.start,
this.maskFilter,
this.clipLinearGradient = false,
this.curve = Curves.linear,
this.restartAnimation = false,
this.onAnimationEnd,
this.widgetIndicator,
this.progressBorderColor,
}) : super(key: key) {
if (linearGradient != null && progressColor != null) {
throw ArgumentError(
'不能同时设置 linearGradient 和 progressColor 属置');
}
_progressColor = progressColor ?? Colors.red;
if (linearGradientBackgroundColor != null && backgroundColor != null) {
throw ArgumentError(
'不能同时设置 linearGradientBackgroundColor 和 backgroundColor 属时');
}
_backgroundColor = backgroundColor ?? const Color(0xFFB8C7CB);
if (percent < 0.0 || percent > 1.0) {
throw Exception(
"百分百值需在 0.0 和 1.0 之间");
}
}