AdvancedListView<T> class

A universal, adaptive, feature-packed replacement for ListView.builder and GridView.builder.

Automatically switches between list and grid layouts based on screen size, with support for skeleton loading, drag & drop, A-Z jump bar, selection modes, animations, and responsive design.

AdvancedListView<Contact>(
  items: contacts,
  layoutMode: LayoutMode.auto,
  itemBuilder: (context, contact, index, constraints) {
    return ContactCard(contact: contact);
  },
)
Inheritance

Constructors

AdvancedListView({Key? key, required List<T> items, required Widget itemBuilder(BuildContext context, T item, int index, BoxConstraints constraints), LayoutMode layoutMode = LayoutMode.auto, SliverGridDelegate? gridDelegate, double? minItemWidth, bool isLoading = false, WidgetBuilder? skeletonBuilder, int skeletonCount = 10, int sortComparator(T a, T b)?, bool sortOrderAscending = true, bool allowReorder = false, void onReorder(int oldIndex, int newIndex)?, Widget indexBarBuilder(BuildContext context)?, ValueChanged<String>? onIndexTap, bool multiSelectEnabled = false, bool singleSelectEnabled = false, ValueChanged<Set<T>>? onSelectionChanged, ValueChanged<T?>? onSelected, Future<void> onRefresh()?, List<Widget> leadingActions(BuildContext context, T item, int index)?, List<Widget> trailingActions(BuildContext context, T item, int index)?, void onLeadingSwipe(T item, int index)?, void onTrailingSwipe(T item, int index)?, Widget? emptyWidget, Widget? errorWidget, ScrollController? scrollController, ScrollPhysics? physics, EdgeInsets? padding, double mainAxisSpacing = 0.0, double crossAxisSpacing = 0.0, double childAspectRatio = 1.0, bool showIndexBar = false, List<String>? indexBarLetters, Duration animationDuration = const Duration(milliseconds: 300), ValueChanged<T>? onItemTap, ValueChanged<T>? onItemLongPress, Key? listKey})
const

Properties

allowReorder bool
Whether drag & drop reordering is enabled.
final
animationDuration Duration
Animation duration for item appearance.
final
childAspectRatio double
Aspect ratio for grid items.
final
crossAxisSpacing double
Spacing between columns (for grid).
final
emptyWidget Widget?
Widget to show when the list is empty.
final
errorWidget Widget?
Widget to show when there's an error.
final
gridDelegate SliverGridDelegate?
Grid delegate for custom grid layouts.
final
hashCode int
The hash code for this object.
no setterinherited
indexBarBuilder Widget Function(BuildContext context)?
Builder for A-Z index bar.
final
indexBarLetters List<String>?
Letters to display in the index bar.
final
isLoading bool
Whether items are currently loading (shows skeleton).
final
itemBuilder Widget Function(BuildContext context, T item, int index, BoxConstraints constraints)
Builder for creating item widgets.
final
items List<T>
The list of items to display.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
layoutMode LayoutMode
Layout mode: auto, list, or grid.
final
leadingActions List<Widget> Function(BuildContext context, T item, int index)?
Leading swipe actions for each item.
final
listKey Key?
Key for the GlobalKey used internally (for testing).
final
mainAxisSpacing double
Spacing between items (for grid).
final
minItemWidth double?
Minimum item width before switching to grid (for auto mode).
final
multiSelectEnabled bool
Whether multi-select mode is enabled.
final
onIndexTap ValueChanged<String>?
Callback when a letter in the index bar is tapped.
final
onItemLongPress ValueChanged<T>?
Callback when an item is long-pressed.
final
onItemTap ValueChanged<T>?
Callback when an item is tapped.
final
onLeadingSwipe → void Function(T item, int index)?
Callback when item is swiped from left to right (revealing leading actions).
final
onRefresh Future<void> Function()?
Callback for pull-to-refresh.
final
onReorder → void Function(int oldIndex, int newIndex)?
Callback when items are reordered via drag & drop.
final
onSelected ValueChanged<T?>?
Callback when item is selected (single-select).
final
onSelectionChanged ValueChanged<Set<T>>?
Callback when selection changes (multi-select).
final
onTrailingSwipe → void Function(T item, int index)?
Callback when item is swiped from right to left (revealing trailing actions).
final
padding EdgeInsets?
Padding around the list.
final
physics ScrollPhysics?
Scroll physics.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollController ScrollController?
Scroll controller for programmatic scrolling.
final
showIndexBar bool
Whether to show the index bar.
final
singleSelectEnabled bool
Whether single-select mode is enabled.
final
skeletonBuilder Widget Function(BuildContext context)?
Builder for skeleton loading items.
final
skeletonCount int
Number of skeleton items to show when loading.
final
sortComparator int Function(T a, T b)?
Comparator for sorting items.
final
sortOrderAscending bool
Sort order: ascending or descending.
final
trailingActions List<Widget> Function(BuildContext context, T item, int index)?
Trailing swipe actions for each item.
final

Methods

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