TTableHeader<T, K>.chip constructor

TTableHeader<T, K>.chip(
  1. String text,
  2. Object? map(
    1. T
    )?, {
  3. int? flex,
  4. double? minWidth,
  5. double? maxWidth,
  6. Alignment? alignment,
  7. Color color(
    1. T
    )?,
  8. dynamic icon(
    1. T
    )?,
  9. TVariant? type,
  10. TVariant? typeBuilder(
    1. T
    )?,
  11. TSize size = TChipSize.sm,
  12. void Function()? onTap(
    1. T
    )?,
  13. String? key,
  14. TFilterType? filterType,
  15. bool filterable = true,
  16. List<TFilterOperator>? filterOperators,
  17. List? filterItems,
  18. TFilterDef<T>? filterDef,
  19. double widthEstimator(
    1. T data
    )?,
  20. bool flattenOnMobile = false,
  21. String mobileKeyPrefixBuilder(
    1. String headerText,
    2. String childKey
    )?,
  22. List<TKeyValue> keyValuesBuilder(
    1. 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,
        );
      });