TKeyValue.progress constructor

TKeyValue.progress(
  1. String key,
  2. double? value, {
  3. double progressMaxWidth = 180.0,
  4. double height = 6.0,
  5. bool showPercentage = true,
  6. String? valueText,
  7. TProgressValuePosition valuePosition = TProgressValuePosition.topRight,
  8. Color? color,
  9. Color? colorBuilder(
    1. double value,
    2. double percentage
    )?,
  10. Color? backgroundColor,
  11. bool flowing = false,
  12. TextStyle? valueStyle,
  13. Widget? icon,
  14. double? width,
  15. Alignment? alignment,
  16. double? minWidth,
  17. double? maxWidth,
})

Creates a key-value item for displaying progress bars using TProgressBar.

Implementation

factory TKeyValue.progress(
  String key,
  double? value, {
  double progressMaxWidth = 180.0,
  double height = 6.0,
  bool showPercentage = true,
  String? valueText,
  TProgressValuePosition valuePosition = TProgressValuePosition.topRight,
  Color? color,
  Color? Function(double value, double percentage)? colorBuilder,
  Color? backgroundColor,
  bool flowing = false,
  TextStyle? valueStyle,
  Widget? icon,
  double? width,
  Alignment? alignment,
  double? minWidth,
  double? maxWidth,
}) {
  Widget? widget;
  if (value != null) {
    widget = ConstrainedBox(
      constraints: BoxConstraints(maxWidth: progressMaxWidth),
      child: TProgressBar(
        value: value,
        height: height,
        showPercentage: showPercentage,
        valueText: valueText,
        valuePosition: valuePosition,
        color: color,
        colorBuilder: colorBuilder,
        backgroundColor: backgroundColor,
        flowing: flowing,
        valueStyle: valueStyle,
      ),
    );
  }
  return TKeyValue(
    key,
    value: value != null ? (valueText ?? '${(value * 100).toInt()}%') : null,
    widget: widget,
    icon: icon,
    width: width,
    alignment: alignment,
    minWidth: minWidth,
    maxWidth: maxWidth,
  );
}