TDataTable<T, K> class

A data table component with pagination, sorting, and expandable rows.

TDataTable provides a full-featured table widget with:

  • Column headers with sorting
  • Pagination with page size selection
  • Server-side data loading
  • Expandable rows for detailed views
  • Responsive layout (mobile/desktop)
  • Infinite scroll on mobile
  • Sticky headers and footers

Basic Usage

TDataTable<User, int>(
  headers: [
    TTableHeader(
      text: 'Name',
      value: (user) => user.name,
      sortable: true,
    ),
    TTableHeader(
      text: 'Email',
      value: (user) => user.email,
    ),
    TTableHeader(
      text: 'Status',
      value: (user) => user.status,
    ),
  ],
  items: users,
  itemsPerPage: 10,
)

With Server-Side Loading

TDataTable<Product, int>(
  headers: productHeaders,
  itemsPerPage: 25,
  onLoad: (page, search) async {
    final response = await api.getProducts(page, search);
    return (response.items, response.hasMore);
  },
)

With Expandable Rows

TDataTable<Order, int>(
  headers: orderHeaders,
  items: orders,
  expandedBuilder: (context, item, index) {
    return OrderDetailsWidget(order: item.data);
  },
)

Type parameters:

  • T: The type of items in the table
  • K: The type of the item key

See also:

Inheritance
Mixed-in types

Constructors

TDataTable({Key? key, required List<TTableHeader<T, K>> headers, TTableTheme? theme, List<T>? items, int? itemsPerPage, String? search, int? searchDelay, TLoadListener<T>? onLoad, ItemKeyAccessor<T, K>? itemKey, TListController<T, K>? controller, TListExpandedBuilder<T, K>? expandedBuilder, int paginationTotalVisible = 7, List<int> itemsPerPageOptions = const [5, 10, 15, 25, 50], TGridMode? grid, TGridDelegateBuilder? gridDelegate, bool? shrinkWrap, TListHeaderBuilder? headerBuilder, TListFooterBuilder? footerBuilder, bool? infiniteScroll, bool? headerSticky, bool? footerSticky, Widget rowBuilder(BuildContext ctx, TListItem<T, K> item, int index, Widget row)?, Color? rowColorBuilder(TListItem<T, K> item, int index)?})
Creates a data table component.
const

Properties

controller TListController<T, K>?
Controller for managing table state.
final
expandedBuilder TListExpandedBuilder<T, K>?
Builder for expanded row content.
final
footerBuilder TListFooterBuilder?
Custom footer builder.
final
footerSticky bool?
Whether the footer should be sticky.
final
grid TGridMode?
Grid layout mode.
final
gridDelegate TGridDelegateBuilder?
Delegate for controlling grid layout.
final
hashCode int
The hash code for this object.
no setterinherited
headerBuilder TListHeaderBuilder?
Custom header builder.
final
headers List<TTableHeader<T, K>>
The column headers for the table.
final
headerSticky bool?
Whether the header should be sticky.
final
infiniteScroll bool?
Whether to enable infinite scroll.
final
itemKey ItemKeyAccessor<T, K>?
Function to extract a unique key from an item.
final
items List<T>?
The list of items to display.
final
itemsPerPage int?
Number of items to display per page.
final
itemsPerPageOptions List<int>
Available options for items per page selection.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onLoad TLoadListener<T>?
Callback for loading items from a server.
final
paginationTotalVisible int
Number of pagination buttons to show.
final
rowBuilder Widget Function(BuildContext ctx, TListItem<T, K> item, int index, Widget row)?
Custom builder for the row.
final
rowColorBuilder Color? Function(TListItem<T, K> item, int index)?
Custom builder for the row background color.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
Initial search query.
final
searchDelay int?
Debounce delay for search in milliseconds.
final
shrinkWrap bool?
Whether the table should shrink-wrap its content.
final
theme TTableTheme?
Custom theme for the table.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TDataTable<T, K>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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