TwoDimensionalChildListDelegate class

A delegate that supplies children for a TwoDimensionalViewport using an explicit two dimensional array.

In general, building all the widgets in advance is not efficient. It is better to create a delegate that builds them on demand using TwoDimensionalChildBuilderDelegate or by subclassing TwoDimensionalChildDelegate directly.

This class is provided for the cases where either the list of children is known well in advance (ideally the children are themselves compile-time constants, for example), and therefore will not be built each time the delegate itself is created, or the array is small, such that it's likely always visible (and thus there is nothing to be gained by building it on demand).

The widgets in the given children list are automatically wrapped in RepaintBoundary widgets if addRepaintBoundaries is true (also the default).

The children are accessed for each ChildVicinity.yIndex and ChildVicinity.xIndex of the TwoDimensionalViewport as children[vicinity.yIndex][vicinity.xIndex].

See also:

Inheritance

Constructors

TwoDimensionalChildListDelegate({bool addRepaintBoundaries = true, bool addAutomaticKeepAlives = true, required List<List<Widget>> children})
Creates a delegate that supplies children for a TwoDimensionalScrollView.

Properties

addAutomaticKeepAlives bool
Whether to wrap each child in an AutomaticKeepAlive.
final
addRepaintBoundaries bool
Whether to wrap each child in a RepaintBoundary.
final
children List<List<Widget>>
The widgets to display.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
build(BuildContext context, ChildVicinity vicinity) Widget?
Returns the child with the given ChildVicinity, which is described in terms of x and y indices.
override
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
shouldRebuild(covariant TwoDimensionalChildListDelegate oldDelegate) bool
Called whenever a new instance of the child delegate class is provided.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited