TTableHeader<T, K> class

Defines a column in TTable.

TTableHeader configures how a column renders, including:

  • Header text and alignment
  • Data mapping from item T
  • Custom cell builders
  • Column sizing (flex, min/max width)
  • Specialized types (image, chip, actions, editable)

Basic Usage

TTableHeader(text: 'Name', map: (user) => user.name)

Specialized Constructors

Constructors

TTableHeader(String text, {Object? map(T)?, Widget builder(BuildContext, TListItem<T, K>, int)?, int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? key, TFilterType? filterType, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, List<TKeyValue> keyValuesBuilder(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?})
Creates a standard table header.
const
TTableHeader.actions(List<TButtonGroupItem> builder(TListItem<T, K>), {String text = "Actions", Alignment? alignment = Alignment.center, int? flex, double? minWidth, double? maxWidth, int? count, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for row actions.
TTableHeader.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(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying chips.
TTableHeader.chips(String text, List<TChip> builder(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, Color? color(T data, String chipText)?, dynamic icon(T data, String chipText)?, TVariant? type, TVariant? typeBuilder(T data, String chipText)?, TSize size = TChipSize.sm, double spacing = 4.0, double runSpacing = 4.0, WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.center, WrapAlignment wrapAlignment = WrapAlignment.start, void Function(String chipText)? onTap(T data)?, String? key, TFilterType? filterType, bool filterable = false, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying multiple chips in a Wrap with auto-calculated width estimation.
TTableHeader.color(String text, String? map(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? label(T)?, String? key, TFilterType? filterType = TFilterType.text, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying hex colors using TColor.
TTableHeader.column(String text, List<Widget> builder(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.start, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center, double spacing = 4.0, String? key, TFilterType? filterType, bool filterable = false, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying multiple widgets vertically in a column in table cells.
TTableHeader.datetime(String text, Object? map(T)?, {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, bool utc = true, String? key, TFilterType? filterType = TFilterType.dateTime, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Create an date formatter
TTableHeader.editable(String text, {required Object? get(T), required Widget builder(BuildContext ctx, T data), Widget displayBuilder(BuildContext ctx, T data)?, String? error(T)?, String? placeholder, int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? key, TFilterType? filterType, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates an editable cell header.
TTableHeader.image(String text, String? map(T), {int? flex, Alignment? alignment, double width = 50, double? minWidth, double? maxWidth, bool forceCache = false, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying images.
TTableHeader.keyValues(String text, List<TKeyValue> builder(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, bool inline = true, double spacing = 4.0, TextStyle? keyStyle, TextStyle? valueStyle, bool flattenOnMobile = true, String mobileKeyPrefixBuilder(String headerText, String childKey)?, String? key, TFilterType? filterType, bool filterable = false, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?})
Creates a header for displaying key-value pairs in table cells.
TTableHeader.map(String text, Object? map(T)?, {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? key, TFilterType? filterType, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?})
Creates a header using only a mapping function.
const
TTableHeader.numberField(String text, num? get(T), void set(T, num?), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? error(T)?, String? placeholder, Widget displayBuilder(BuildContext ctx, T data)?, String? key, TFilterType filterType = TFilterType.number, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?})
Creates an editable number field header.
TTableHeader.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(double value, double percentage)?, 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(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying progress bars in table cells using TProgressBar.
TTableHeader.rating(String text, double? map(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, int itemCount = 5, double itemSize = 10.0, Color? color, Color? unratedColor, bool allowHalfRating = false, double spacing = 0.0, 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(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying ratings.
TTableHeader.row(String text, List<Widget> builder(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, double spacing = 8.0, double runSpacing = 4.0, WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.center, WrapAlignment wrapAlignment = WrapAlignment.start, String? key, TFilterType? filterType, bool filterable = false, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying multiple widgets in a horizontal row/wrap in table cells.
TTableHeader.textField(String text, String? get(T), void set(T, String?), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? error(T)?, String? placeholder, Widget displayBuilder(BuildContext ctx, T data)?, String? key, TFilterType filterType = TFilterType.text, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?})
Creates an editable text field header.
TTableHeader.tile(String text, String? title(T), {String? subtitle(T)?, dynamic icon(T)?, dynamic leading(T)?, Color? iconColor(T)?, Color? iconBackgroundColor(T)?, TextStyle? titleStyle, TextStyle? subtitleStyle, double? iconSize, EdgeInsetsGeometry? iconPadding, BorderRadius? iconBorderRadius, double spacing = 10.0, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center, Widget trailing(T)?, int? flex, double? minWidth, double? maxWidth, Alignment? alignment, String? key, TFilterType? filterType = TFilterType.text, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying a title and optional subtitle with leading icon using TTile.
TTableHeader.toggle(String text, bool? get(T), void set(T, bool)?, {int? flex, double? minWidth, double? maxWidth, Alignment? alignment = Alignment.center, bool disabled = false, bool isDisabled(T data)?, String? key, TFilterType? filterType = TFilterType.boolean, bool filterable = true, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, Color? color, Color? inactiveColor, double widthEstimator(T data)?, bool flattenOnMobile = false, String mobileKeyPrefixBuilder(String headerText, String childKey)?, List<TKeyValue> keyValuesBuilder(T data)?})
Creates a header for displaying and editing boolean values using TSwitch.
TTableHeader.values(String text, List<TKeyValue> builder(T), {int? flex, double? minWidth, double? maxWidth, Alignment? alignment, double spacing = 2.0, CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.start, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center, bool flattenOnMobile = true, String mobileKeyPrefixBuilder(String headerText, String childKey)?, String? key, TFilterType? filterType, bool filterable = false, List<TFilterOperator>? filterOperators, List? filterItems, TFilterDef<T>? filterDef, double widthEstimator(T data)?})
Creates a header for displaying a list of values with hierarchical font sizes and adaptive contrast in table cells, automatically flattened on mobile card views.

Properties

alignment → Alignment?
Alignment of content within the cell.
final
builder → Widget Function(BuildContext, TListItem<T, K>, int)?
Custom builder for cell content.
final
filterable → bool
Whether this column can be filtered in CRUD table filter forms. Defaults to true if map is non-null.
final
filterDef → TFilterDef<T>?
Optional explicit filter definition override for this column.
final
filterItems → List?
Optional list of items for enum/select filters.
final
filterOperators → List<TFilterOperator>?
Optional custom list of filter operators for this column.
final
filterType → TFilterType?
Underlying filter data type for auto-generated filter fields.
final
flattenOnMobile → bool
Whether sub-keyValues should be unpacked as individual flat rows on mobile cards. Defaults to true for TTableHeader.keyValues.
final
flex → int?
Flex factor for column width.
final
hashCode → int
The hash code for this object.
no setterinherited
key → String?
Optional unique key for filtering (defaults to camelCase of text).
final
keyValuesBuilder → List<TKeyValue> Function(T data)?
The underlying key-value generator when created via TTableHeader.keyValues.
final
map → Object? Function(T)?
Function to extract cell value from item.
final
maxWidth → double?
Maximum width of the column.
final
minWidth → double?
Minimum width of the column.
final
mobileKeyPrefixBuilder → String Function(String headerText, String childKey)?
Optional prefix or formatting hook when flattened on mobile (e.g. (header, key) => '$header: $key').
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
text → String
The header label text.
final
widthEstimator → double Function(T data)?
Optional explicit width estimator for cells whose true rendered size can't be inferred by measuring map's raw value as plain text (e.g. a chip's padding/border, a star rating's icon row, a switch's fixed track size). Given the same T the column measures, return an estimated unwrapped pixel width for that cell. Takes priority over both map-based text measurement and the flat fallback used when there's no map at all.
final

Methods

getTextAlign() → TextAlign
Gets the text alignment based on alignment.
getValue(T item) → String
Gets the string display value for an item.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toKeyValues(BuildContext ctx, TListItem<T, K> item, int index) → List<TKeyValue>
Converts this header into one or more TKeyValue items for mobile card representations.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

autoGenerateFilterDefs<T, K>(List<TTableHeader<T, K>> headers, {List<T>? sampleItems}) → List<TFilterDef<T>>
Automatically generates a list of TFilterDefs from the given headers and optional sampleItems to infer field data types.