TTableHeader<T, K>.progress constructor
TTableHeader<T, K>.progress (
- String text,
- double? map(
- T
- int? flex,
- double? minWidth,
- double? maxWidth,
- Alignment? alignment,
- double progressMaxWidth = 200,
- double height = 4.0,
- bool showPercentage = true,
- String? valueText(
- T
- TProgressValuePosition valuePosition = TProgressValuePosition.topRight,
- Color? color,
- Color? colorBuilder()?,
- Color? backgroundColor,
- bool flowing = false,
- TextStyle? valueStyle,
- String? key,
- TFilterType? filterType = TFilterType.number,
- bool filterable = true,
- List<
TFilterOperator> ? filterOperators, - List? filterItems,
- TFilterDef<
T> ? filterDef, - double widthEstimator(
- T data
- bool flattenOnMobile = false,
- String mobileKeyPrefixBuilder()?,
- List<
TKeyValue> keyValuesBuilder(- 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,
),
);
});