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
Available extensions

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, WidgetBuilder? beforeItemsBuilder, TGridMode? grid, TGridDelegateBuilder? gridDelegate, bool? shrinkWrap, TListHeaderBuilder? headerBuilder, TListFooterBuilder? footerBuilder, bool? infiniteScroll, bool? headerSticky, bool? footerSticky, EdgeInsets? padding})
Creates a list component.

Properties

autoItemsPerPage bool
Whether to automatically calculate items per page based on height.
final
beforeItemsBuilder WidgetBuilder?
Builder for content before the list items.
final
cardTheme TListCardTheme?
Custom theme for list item cards.
final
controller TListController<T, K>?
Controller for managing list state.
final
footerBuilder WidgetBuilder?
Custom footer widget.
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 WidgetBuilder?
Custom header widget.
final
headerSticky bool?
Whether the header should be sticky.
final
infiniteScroll bool?
Whether to enable infinite scroll.
final
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
padding EdgeInsets?
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
shrinkWrap bool?
Whether the list should shrink-wrap its content.
final
theme TListTheme?
Custom theme for the list.
final

Methods

box({double minW = 0.0, double minH = 0.0, double maxW = double.infinity, double maxH = double.infinity}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a ConstrainedBox to apply layout constraints.
center({bool when = true}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Center widget.
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
expanded({int flex = 1}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in an Expanded widget.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
padding([double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0]) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Padding with flexible edge control.
paddingSymmetric({double h = 0.0, double v = 0.0}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Padding with symmetric horizontal and vertical spacing.
size({double? w, double? h}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a SizedBox to apply fixed width and/or height.
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
visible(bool visible, {bool maintainState = false}) Widget

Available on Widget, provided by the WidgetX extension

Wraps this widget in a Visibility widget.
when(bool condition) Widget

Available on Widget, provided by the WidgetX extension

Returns this widget if condition is true, otherwise returns SizedBox.shrink(). Usage: Text('Hello').when(isVisible)

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