TTableHeader<T, K>.chip constructor
TTableHeader<T, K>.chip (
- String text,
- Object? map(
- T
- int? flex,
- double? minWidth,
- double? maxWidth,
- Alignment? alignment,
- Color color(
- T
- dynamic icon(
- T
- TVariant? type,
- TVariant? typeBuilder(
- T
- TSize size = TChipSize.sm,
- void Function()? onTap(
- T
- String? key,
- TFilterType? filterType,
- 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 chips.
Implementation
TTableHeader.chip(
this.text,
this.map, {
this.flex,
this.minWidth,
this.maxWidth,
this.alignment,
Color Function(T)? color,
dynamic Function(T)? icon,
TVariant? type,
TVariant? Function(T)? typeBuilder,
TSize size = TChipSize.sm,
void Function()? Function(T)? onTap,
this.key,
this.filterType,
this.filterable = true,
this.filterOperators,
this.filterItems,
this.filterDef,
double Function(T data)? widthEstimator,
this.flattenOnMobile = false,
this.mobileKeyPrefixBuilder,
this.keyValuesBuilder,
}) : widthEstimator = widthEstimator ??
((data) {
final text = map?.call(data)?.toString() ?? '';
if (text.isEmpty) return 0.0;
final hasIcon = icon != null && icon(data) != null;
return TTableTheme.measureTextWidth(text) + 24.0 + (hasIcon ? 18.0 : 0.0);
}),
builder = ((ctx, item, __) {
final isDense = TTableScope.maybeOf(ctx)?.dense ?? false;
return TChip(
text: map?.call(item.data).toString(),
icon: icon?.call(item.data),
color: color?.call(item.data),
type: typeBuilder?.call(item.data) ?? type,
size: size,
onTap: onTap?.call(item.data),
padding: isDense ? const EdgeInsets.symmetric(horizontal: 6, vertical: 2) : null,
);
});