LinearProgressBar constructor

LinearProgressBar({
  1. Key? key,
  2. Color fillColor = Colors.transparent,
  3. double percent = 0.0,
  4. double lineHeight = 5.0,
  5. double? width,
  6. Color? backgroundColor,
  7. LinearGradient? linearGradientBackgroundColor,
  8. LinearGradient? linearGradient,
  9. Color? progressColor,
  10. bool animation = false,
  11. int animationDuration = 500,
  12. bool animateFromLastPercent = false,
  13. bool isRTL = false,
  14. Widget? leading,
  15. Widget? trailing,
  16. Widget? center,
  17. bool addAutomaticKeepAlive = true,
  18. Radius? barRadius,
  19. EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 10.0),
  20. MainAxisAlignment alignment = MainAxisAlignment.start,
  21. MaskFilter? maskFilter,
  22. bool clipLinearGradient = false,
  23. Curve curve = Curves.linear,
  24. bool restartAnimation = false,
  25. VoidCallback? onAnimationEnd,
  26. Widget? widgetIndicator,
  27. 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 之间");
  }
}