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, Widget expandedBuilder(BuildContext ctx, TListItem<T, K> item, int index)?, int paginationTotalVisible = 7, List<int> itemsPerPageOptions = const [5, 10, 15, 25, 50]})
Creates a data table component.
const

Properties

controller TListController<T, K>?
Controller for managing table state.
final
expandedBuilder Widget Function(BuildContext ctx, TListItem<T, K> item, int index)?
Builder for expanded row content.
final
hashCode int
The hash code for this object.
no setterinherited
headers List<TTableHeader<T, K>>
The column headers for the table.
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
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
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