TTableHeader<T, K>.progress constructor

TTableHeader<T, K>.progress(
  1. String text,
  2. double? map(
    1. T
    ), {
  3. int? flex,
  4. double? minWidth,
  5. double? maxWidth,
  6. Alignment? alignment,
  7. double progressMaxWidth = 200,
  8. double height = 4.0,
  9. bool showPercentage = true,
  10. String? valueText(
    1. T
    )?,
  11. TProgressValuePosition valuePosition = TProgressValuePosition.topRight,
  12. Color? color,
  13. Color? colorBuilder(
    1. double value,
    2. double percentage
    )?,
  14. Color? backgroundColor,
  15. bool flowing = false,
  16. TextStyle? valueStyle,
  17. String? key,
  18. TFilterType? filterType = TFilterType.number,
  19. bool filterable = true,
  20. List<TFilterOperator>? filterOperators,
  21. List? filterItems,
  22. TFilterDef<T>? filterDef,
  23. double widthEstimator(
    1. T data
    )?,
  24. bool flattenOnMobile = false,
  25. String mobileKeyPrefixBuilder(
    1. String headerText,
    2. String childKey
    )?,
  26. List<TKeyValue> keyValuesBuilder(
    1. T data
    )?,
})

Creates a header for displaying progress bars in table cells using TProgressBar.

Implementation

TTableHeader.progress(
  this.text,
  double? Function(T) map, {
  this.flex,
  this.minWidth,
  this.maxWidth,
  this.alignment,
  double progressMaxWidth = 200,
  double height = 4.0,
  bool showPercentage = true,
  String? Function(T)? valueText,
  TProgressValuePosition valuePosition = TProgressValuePosition.topRight,
  Color? color,
  Color? Function(double value, double percentage)? colorBuilder,
  Color? backgroundColor,
  bool flowing = false,
  TextStyle? valueStyle,
  this.key,
  this.filterType = TFilterType.number,
  this.filterable = true,
  this.filterOperators,
  this.filterItems,
  this.filterDef,
  double Function(T data)? widthEstimator,
  this.flattenOnMobile = false,
  this.mobileKeyPrefixBuilder,
  this.keyValuesBuilder,
})  : map = map,
      widthEstimator = widthEstimator ??
          _defaultProgressWidthEstimator(
            map: map,
            valueText: valueText,
            showPercentage: showPercentage,
            valuePosition: valuePosition,
            progressMaxWidth: progressMaxWidth,
          ),
      builder = ((ctx, item, __) {
        final scope = TTableScope.maybeOf(ctx);
        final isDense = scope?.dense ?? false;
        final val = map(item.data) ?? 0.0;
        final customValueText = valueText?.call(item.data);

        final contentStyle = scope?.contentTextStyle ?? ctx.theme.tableTheme.rowCardTheme.contentTextStyle;
        final fallbackValStyle = TextStyle(
          fontSize: isDense ? 10 : 11.0,
          fontWeight: FontWeight.w400,
        );
        final defaultValStyle = contentStyle?.adjust(sizeMultiplier: 0.8, weightStep: 1, clearColor: true) ?? fallbackValStyle;
        final effectiveValueStyle = valueStyle != null ? defaultValStyle.merge(valueStyle) : defaultValStyle;

        final effectiveEstimator = widthEstimator ??
            _defaultProgressWidthEstimator(
              map: map,
              valueText: valueText,
              showPercentage: showPercentage,
              valuePosition: valuePosition,
              progressMaxWidth: progressMaxWidth,
            );
        final estimatedWidth = effectiveEstimator(item.data);

        return ConstrainedBox(
          constraints: BoxConstraints(maxWidth: estimatedWidth),
          child: TProgressBar(
            value: val,
            height: isDense ? (height * 0.75).clamp(3.0, 12.0) : height,
            showPercentage: showPercentage,
            valueText: customValueText,
            valuePosition: valuePosition,
            color: color,
            colorBuilder: colorBuilder,
            backgroundColor: backgroundColor,
            flowing: flowing,
            valueStyle: effectiveValueStyle,
          ),
        );
      });