LazyWrap class
A performant scrollable wrap widget for Flutter, combining the layout behavior of Wrap with the lazy rendering of ListView.
Use LazyWrap.fixed for items with known, uniform sizes (best performance). Use LazyWrap.dynamic for items with variable or unknown sizes.
Both modes support vertical and horizontal scrolling via scrollDirection.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- LazyWrap
Constructors
- LazyWrap.dynamic({required int itemCount, required Widget itemBuilder(BuildContext, int), Key? key, double spacing = 8, double runSpacing = 8, EdgeInsetsGeometry padding = EdgeInsets.zero, MainAxisAlignment rowAlignment = MainAxisAlignment.start, Axis scrollDirection = Axis.vertical, double cacheExtent = 300, int? batchSize = 50, Widget loadingBuilder(BuildContext)?, bool fadeInItems = true, Duration? fadeInDuration = const Duration(milliseconds: 200), Curve? fadeInCurve = Curves.easeOut, ScrollController? controller, double? loadThreshold = 300, int? measureBatchSize = 15, LazyWrapEngine? engine = LazyWrapEngine.offstageV1, double itemWidthBuilder(int)?, double itemHeightBuilder(int)?})
-
Creates a LazyWrap for items with variable sizes.
const
- LazyWrap.fixed({required int itemCount, required Widget itemBuilder(BuildContext, int), required double? estimatedItemWidth, required double? estimatedItemHeight, Key? key, double spacing = 8, double runSpacing = 8, EdgeInsetsGeometry padding = EdgeInsets.zero, MainAxisAlignment rowAlignment = MainAxisAlignment.start, Axis scrollDirection = Axis.vertical, double cacheExtent = 300})
-
Creates a LazyWrap for items with known, uniform sizes.
const
Properties
- batchSize → int?
-
Items to load per batch (dynamic mode only). Default: 50.
final
- cacheExtent → double
-
Pixels to pre-render beyond the viewport for smoother scrolling.
Default: 300.
final
- controller → ScrollController?
-
Optional external scroll controller (dynamic mode only).
final
- engine → LazyWrapEngine?
-
Dynamic engine selection (dynamic mode only).
final
- estimatedItemHeight → double?
-
Height of each item (required for fixed mode, ignored in dynamic mode).
final
- estimatedItemWidth → double?
-
Width of each item (required for fixed mode, ignored in dynamic mode).
final
- fadeInCurve → Curve?
-
Curve of fade-in animation (dynamic mode only). Default: Curves.easeOut.
final
- fadeInDuration → Duration?
-
Duration of fade-in animation (dynamic mode only). Default: 200ms.
final
- fadeInItems → bool
-
Whether items fade in when first appearing (dynamic mode only).
Default: true.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDynamic → bool
-
Whether using dynamic measurement mode.
final
- itemBuilder → Widget Function(BuildContext, int)
-
Builder function called to create each item widget.
final
- itemCount → int
-
Total number of items to display.
final
- itemHeightBuilder → double Function(int)?
-
Deterministic height builder used by
sliverV2(dynamic mode only).final - itemWidthBuilder → double Function(int)?
-
Deterministic width builder used by
sliverV2(dynamic mode only).final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadingBuilder → Widget Function(BuildContext)?
-
Custom loading indicator (dynamic mode only).
final
- loadThreshold → double?
-
Distance from the end at which to trigger loading (dynamic mode only).
Default: 300.
final
- measureBatchSize → int?
-
Max items measured per frame in Offstage (dynamic mode only).
Default: 15.
final
- padding → EdgeInsetsGeometry
-
Padding around the entire wrap content. Default: EdgeInsets.zero.
final
- rowAlignment → MainAxisAlignment
-
Alignment of items within each row. Default: MainAxisAlignment.start.
final
- runSpacing → double
-
Vertical spacing between rows. Default: 8.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis
-
Scroll direction. Default: Axis.vertical.
final
- spacing → double
-
Horizontal spacing between items within a row. Default: 8.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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