LazyIndexedStackPlus class

A widget that behaves like IndexedStack but loads its children lazily.

Unlike a standard IndexedStack, which inflates all children immediately, LazyIndexedStackPlus only builds a child when it first becomes active (the index matches) or if it is included in preloadIndexes.

Once a child has been built, it is kept in the widget tree to maintain its state (e.g., scroll position, text input).

This sample shows the usage of LazyIndexedStackPlus

LazyIndexedStackPlus(
  index: 0,
  preloadIndexes: {1}, // Optional: Preload specific tabs /indexes
  placeholder: Center(child: CircularProgressIndicator()),
  children: [
    HomeTab(),
    ProfileTab(),
    SettingsTab(),
  ],
);

See also:

Inheritance

Constructors

LazyIndexedStackPlus({Key? key, int index = 0, AlignmentGeometry alignment = AlignmentDirectional.topStart, StackFit sizing = StackFit.loose, Clip clipBehavior = Clip.hardEdge, TextDirection? textDirection, Widget placeholder = const SizedBox.shrink(), Set<int> preloadIndexes = const <int>{}, List<Widget> children = const <Widget>[]})
A widget that behaves like IndexedStack but loads its children lazily.
const

Properties

alignment AlignmentGeometry
How to align the children in the stack.
final
children List<Widget>
The list of widgets to be displayed in the stack.
final
clipBehavior Clip
Whether to clip the overflow of children.
final
hashCode int
The hash code for this object.
no setterinherited
index int
The index of the child to show.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
placeholder Widget
The widget to display for children that have not been initialized yet.
final
preloadIndexes Set<int>
A set of indexes that should be built immediately, even if they are not the current index.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sizing StackFit
How to size the non-positioned children in the stack.
final
textDirection TextDirection?
The text direction with which to resolve alignment.
final

Methods

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