TList<T, K> class

A powerful list component with pagination, search, and infinite scroll.

TList provides a feature-rich list widget with:

  • Pagination with automatic or manual items per page
  • Server-side data loading with onLoad
  • Search and filtering
  • Infinite scroll support
  • Reorderable items
  • Grid layout support
  • Selection (single/multiple)
  • Expandable/hierarchical items
  • Custom animations
  • Scroll position tracking

Basic Usage

TList<String, String>(
  items: ['Item 1', 'Item 2', 'Item 3'],
  itemBuilder: (context, item, index) {
    return ListTile(title: Text(item.data));
  },
)

With Server-Side Loading

TList<Product, int>(
  itemsPerPage: 10,
  itemKey: (product) => product.id,
  onLoad: (page, search) async {
    final response = await api.getProducts(page, search);
    return (response.items, response.hasMore);
  },
  itemTitle: (product) => product.name,
  itemSubTitle: (product) => product.description,
)
TList<User, int>(
  items: users,
  search: searchQuery,
  searchDelay: 300,
  itemKey: (user) => user.id,
  itemTitle: (user) => user.name,
)

Type parameters:

  • T: The type of items in the list
  • K: The type of the item key (for tracking items)

See also:

Inheritance
Mixed-in types

Constructors

TList({Key? key, TListTheme? theme, List<T>? items, int? itemsPerPage, String? search, int? searchDelay, TLoadListener<T>? onLoad, ItemKeyAccessor<T, K>? itemKey, TListController<T, K>? controller, ScrollController? scrollController, VoidCallback? onScrollEnd, double scrollEndThreshold = 0.0, ValueNotifier<double>? scrollPositionNotifier, ValueChanged<double>? onScrollPositionChanged, bool autoItemsPerPage = true, TListCardTheme? cardTheme, ItemTextAccessor<T>? itemTitle, ItemTextAccessor<T>? itemSubTitle, ItemTextAccessor<T>? itemImageUrl, ListItemTap<T, K>? onTap, ListItemBuilder<T, K>? itemBuilder})
Creates a list component.

Properties

autoItemsPerPage bool
Whether to automatically calculate items per page based on height.
final
cardTheme TListCardTheme?
Custom theme for list item cards.
final
controller TListController<T, K>?
Controller for managing list state.
final
hashCode int
The hash code for this object.
no setterinherited
itemBuilder ListItemBuilder<T, K>
Custom builder for rendering each list item.
final
itemImageUrl ItemTextAccessor<T>?
Function to extract image URL from an item.
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
itemSubTitle ItemTextAccessor<T>?
Function to extract subtitle text from an item.
final
itemTitle ItemTextAccessor<T>?
Function to extract title text from an item.
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
onScrollEnd VoidCallback?
Callback fired when scrolled to the end.
final
onScrollPositionChanged ValueChanged<double>?
Callback fired when scroll position changes.
final
onTap ListItemTap<T, K>?
Callback fired when an item is tapped.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
Custom scroll controller.
final
scrollEndThreshold double
Threshold distance from bottom to trigger scroll end.
final
scrollPositionNotifier ValueNotifier<double>?
ValueNotifier for tracking scroll position (0.0 to 1.0).
final
Initial search query.
final
searchDelay int?
Debounce delay for search in milliseconds.
final
theme TListTheme?
Custom theme for the list.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TList<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

Static Methods

defaultItemBuilder<T, K>(TListCardTheme? theme, ItemTextAccessor<T>? itemTitle, ItemTextAccessor<T>? itemSubTitle, ItemTextAccessor<T>? itemImageUrl, ListItemTap<T, K>? onTap) ListItemBuilder<T, K>
defaultItemTitle<T>(T item) String