### Install lazy_wrap Package Source: https://pub.dev/documentation/lazy_wrap/latest/index This snippet shows how to add the lazy_wrap package as a dependency to your Flutter project. Ensure you are using a compatible version. ```yaml dependencies: lazy_wrap: ^1.0.0 ``` -------------------------------- ### Flutter LazyWrapView Example Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap Demonstrates the basic usage of the LazyWrapView widget in Flutter. This widget efficiently displays a large number of children by only rendering those currently visible on the screen. It's ideal for performance-critical UIs with extensive lists. ```dart LazyWrapView( children: List.generate(1000, (i) => Text('Item $i')), ) ``` -------------------------------- ### LazyWrap.dynamic Constructor Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/LazyWrap.dynamic The dynamic constructor for LazyWrap allows for lists with variable-sized widgets. It measures items invisibly before display to prevent layout jumps and supports an optional fade-in animation. ```APIDOC ## LazyWrap.dynamic Constructor ### Description Creates a LazyWrap widget with dynamic item sizing. This constructor is ideal for lists where widget heights or widths can vary, as it measures items invisibly before rendering to ensure a smooth user experience and prevent layout shifts. It also supports a fade-in animation for newly loaded items. ### Method Constructor ### Endpoint N/A (Dart Constructor) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **itemCount** (int) - Required - The total number of items in the list. - **itemBuilder** (Widget Function(BuildContext, int)) - Required - A function that builds each item in the list. It receives the BuildContext and the item index. - **key** (Key?) - Optional - A Key to identify this widget. - **spacing** (double) - Optional - The spacing between items in the main axis. Defaults to 8.0. - **runSpacing** (double) - Optional - The spacing between items in the cross axis. Defaults to 8.0. - **padding** (EdgeInsetsGeometry) - Optional - Padding around the entire widget. Defaults to EdgeInsets.zero. - **rowAlignment** (MainAxisAlignment) - Optional - The alignment of items within a run. Defaults to MainAxisAlignment.start. - **scrollDirection** (Axis) - Optional - The direction of scrolling. Defaults to Axis.vertical. - **cacheExtent** (double) - Optional - The distance from the edges of the viewport that items should be kept in memory. Defaults to 300.0. - **batchSize** (int?) - Optional - The number of items to load in each batch. Defaults to 50. - **loadingBuilder** (Widget Function(BuildContext)?) - Optional - A builder for displaying a loading indicator while items are being fetched. - **fadeInItems** (bool) - Optional - Whether to enable fade-in animation for items. Defaults to true. - **fadeInDuration** (Duration?) - Optional - The duration of the fade-in animation. Defaults to 200 milliseconds. - **fadeInCurve** (Curve?) - Optional - The curve for the fade-in animation. Defaults to Curves.easeOut. ### Request Example ```dart LazyWrap.dynamic( itemCount: 100, itemBuilder: (context, index) { return Container( width: 100.0, // Example variable size height: (index % 5 * 20.0) + 50.0, // Example variable size color: Colors.blue, child: Center(child: Text('Item $index')), ); }, spacing: 10.0, runSpacing: 10.0, fadeInItems: true, fadeInDuration: Duration(milliseconds: 300), ) ``` ### Response #### Success Response (200) N/A (This is a constructor, not an endpoint returning data) #### Response Example N/A ``` -------------------------------- ### LazyWrap Properties Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap-class Overview of the properties available for the LazyWrap widget, including configuration for dynamic and fixed modes, layout, and appearance. ```APIDOC ## LazyWrap Properties ### Description Properties that configure the behavior and appearance of the LazyWrap widget. ### Properties List - **batchSize** (int?): Only for dynamic mode. Items per batch. Default: 50. - **cacheExtent** (double): Defines the cache area beyond the visible viewport. - **estimatedItemHeight** (double?): Estimated height for items in fixed mode. - **estimatedItemWidth** (double?): Estimated width for items in fixed mode. - **fadeInCurve** (Curve?): Only for dynamic mode. Fade-in curve for items. Default: Curves.easeOut. - **fadeInDuration** (Duration?): Only for dynamic mode. Fade-in duration for items. Default: 200ms. - **fadeInItems** (bool): Only for dynamic mode. Whether items fade in. Default: true. - **isDynamic** (bool): Indicates if the widget is in dynamic mode. - **itemBuilder** (Widget Function(BuildContext, int)): Function to build each item in the wrap. - **itemCount** (int): The total number of items to display. - **key** (Key?): Controls how one widget replaces another widget in the tree. - **loadingBuilder** (Widget Function(BuildContext)?): Only for dynamic mode. Custom loading indicator widget. - **padding** (EdgeInsetsGeometry): Padding around the wrap. - **rowAlignment** (MainAxisAlignment): Alignment of items along the main axis of each run. - **runSpacing** (double): Spacing between runs (rows or columns). - **scrollDirection** (Axis): The direction in which the wrap scrolls. - **spacing** (double): Spacing between items within a run. ``` -------------------------------- ### LazyWrap Dynamic Mode Usage (Flutter) Source: https://pub.dev/documentation/lazy_wrap/latest/index Illustrates the usage of LazyWrap in 'dynamic' mode, designed for lists with items of varying sizes. This mode supports optional features like fade-in animations and custom loading indicators. ```dart LazyWrap.dynamic( itemCount: 10000, itemBuilder: (context, index) => VariableCard(index), spacing: 8, runSpacing: 8, // Optional customization fadeInItems: true, // Smooth fade-in animation fadeInDuration: Duration(ms: 200), batchSize: 50, // Items per batch loadingBuilder: (ctx) => MyLoader(), // Custom loading indicator ) ``` -------------------------------- ### LazyWrap Fixed Mode Usage (Flutter) Source: https://pub.dev/documentation/lazy_wrap/latest/index Demonstrates the usage of LazyWrap in 'fixed' mode, suitable for lists where all items have the same dimensions. It requires estimated item dimensions for optimal performance. ```dart LazyWrap.fixed( itemCount: 10000, estimatedItemWidth: 120, estimatedItemHeight: 100, itemBuilder: (context, index) => ProductCard(index), spacing: 8, runSpacing: 8, ) ``` -------------------------------- ### fadeInItems Property Configuration Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/fadeInItems This section describes the 'fadeInItems' property, which controls whether items fade in for dynamic mode in the lazy wrap website. ```APIDOC ## fadeInItems Property ### Description Controls whether items fade in when in dynamic mode. This property is applicable only for dynamic mode. ### Method N/A (Configuration Property) ### Endpoint N/A (Configuration Property) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **fadeInItems** (boolean) - Optional - Whether items fade in. Default: true. ### Request Example ```json { "fadeInItems": true } ``` ### Response #### Success Response (200) - **fadeInItems** (boolean) - Indicates if items fade in. Returns the configured value. #### Response Example ```json { "fadeInItems": true } ``` ``` -------------------------------- ### LazyWrap.dynamic Constructor in Dart Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/LazyWrap.dynamic The `LazyWrap.dynamic` constructor is used for creating scrollable lists with dynamically sized widgets. It requires an `itemCount` and an `itemBuilder` function. Optional parameters control spacing, alignment, scroll direction, caching, batching, and fade-in animations. ```dart const LazyWrap.dynamic({ required this.itemCount, required this.itemBuilder, super.key, this.spacing = 8, this.runSpacing = 8, this.padding = EdgeInsets.zero, this.rowAlignment = MainAxisAlignment.start, this.scrollDirection = Axis.vertical, this.cacheExtent = 300, this.batchSize = 50, this.loadingBuilder, this.fadeInItems = true, this.fadeInDuration = const Duration(milliseconds: 200), this.fadeInCurve = Curves.easeOut, }) : isDynamic = true, estimatedItemWidth = null, estimatedItemHeight = null; ``` -------------------------------- ### LazyWrap.fixed Constructor Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/LazyWrap.fixed The `LazyWrap.fixed` constructor is used for creating a LazyWrap widget where all items have approximately the same dimensions. This mode is optimized for performance when item sizes are predictable. ```APIDOC ## LazyWrap.fixed Constructor ### Description Creates a LazyWrap widget optimized for lists or grids where all items are of a similar, fixed size. This constructor requires estimated dimensions for items to efficiently manage rendering and scrolling. ### Method Constructor ### Endpoint N/A (Widget Constructor) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters * **itemCount** (int) - Required - The total number of items to display. * **itemBuilder** (Widget Function) - Required - A function that builds each item widget. It receives the BuildContext and the item index. * **estimatedItemWidth** (double?) - Required - The estimated width of each item. Must be greater than 0 for fixed mode. * **estimatedItemHeight** (double?) - Required - The estimated height of each item. Must be greater than 0 for fixed mode. * **key** (Key?) - Optional - An optional key for the widget. * **spacing** (double) - Optional - The horizontal space between items. Defaults to 8.0. * **runSpacing** (double) - Optional - The vertical space between runs of items. Defaults to 8.0. * **padding** (EdgeInsetsGeometry) - Optional - Padding around the entire widget. Defaults to EdgeInsets.zero. * **rowAlignment** (MainAxisAlignment) - Optional - The alignment of items within a run. Defaults to MainAxisAlignment.start. * **scrollDirection** (Axis) - Optional - The direction of scrolling. Defaults to Axis.vertical. * **cacheExtent** (double) - Optional - The distance from the edges of the viewport beyond which items are no longer rendered. Defaults to 300.0. ### Request Example ```dart LazyWrap.fixed( itemCount: 100, itemBuilder: (context, index) => MyItemWidget(index: index), estimatedItemWidth: 150.0, estimatedItemHeight: 100.0, spacing: 10.0, runSpacing: 10.0, ) ``` ### Response #### Success Response (200) N/A (Widget Constructor) #### Response Example N/A (Widget Constructor) ``` -------------------------------- ### Define loadingBuilder Property Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/loadingBuilder This snippet shows the definition of the loadingBuilder property. It is a function that takes a BuildContext and returns a Widget, intended for custom loading indicators in dynamic mode. ```dart final Widget Function(BuildContext)? loadingBuilder; ``` -------------------------------- ### LazyWrap.fixed Constructor in Dart Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/LazyWrap.fixed The `LazyWrap.fixed` constructor is used for creating a lazily loaded list or grid where items are of a consistent size. It requires essential parameters like `itemCount`, `itemBuilder`, `estimatedItemWidth`, and `estimatedItemHeight` for optimal performance. This constructor is suitable for fixed-size layouts and includes assertions to ensure valid dimensions are provided. ```dart const LazyWrap.fixed({ required this.itemCount, required this.itemBuilder, required this.estimatedItemWidth, required this.estimatedItemHeight, super.key, this.spacing = 8, this.runSpacing = 8, this.padding = EdgeInsets.zero, this.rowAlignment = MainAxisAlignment.start, this.scrollDirection = Axis.vertical, this.cacheExtent = 300, }) : isDynamic = false, batchSize = null, loadingBuilder = null, fadeInItems = false, fadeInDuration = null, fadeInCurve = null, assert( estimatedItemWidth != null && estimatedItemWidth > 0, 'estimatedItemWidth must be provided and > 0 for fixed mode', ), assert( estimatedItemHeight != null && estimatedItemHeight > 0, 'estimatedItemHeight must be provided and > 0 for fixed mode', ); ``` -------------------------------- ### Build Method for Lazy Wrap Widget (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/build Overrides the build method to conditionally render either a DynamicLazyWrap or a FixedLazyWrap widget. It takes a BuildContext and returns the appropriate widget based on the 'isDynamic' flag. This method is called by the framework when the widget is inserted into the tree or when its dependencies change. ```dart @override Widget build(BuildContext context) { if (isDynamic) { return DynamicLazyWrap( itemCount: itemCount, itemBuilder: itemBuilder, spacing: spacing, runSpacing: runSpacing, padding: padding, rowAlignment: rowAlignment, scrollDirection: scrollDirection, cacheExtent: cacheExtent, batchSize: batchSize ?? 50, loadingBuilder: loadingBuilder, fadeInItems: fadeInItems, fadeInDuration: fadeInDuration ?? const Duration(milliseconds: 200), fadeInCurve: fadeInCurve ?? Curves.easeOut, ); } else { return FixedLazyWrap( itemCount: itemCount, itemBuilder: itemBuilder, spacing: spacing, runSpacing: runSpacing, padding: padding, estimatedItemWidth: estimatedItemWidth!, estimatedItemHeight: estimatedItemHeight!, rowAlignment: rowAlignment, scrollDirection: scrollDirection, cacheExtent: cacheExtent, ); } } ``` -------------------------------- ### Implement itemCount Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/itemCount Provides the implementation for the 'itemCount' property, declaring it as a final integer. This ensures the count is set once and remains immutable. ```dart final int itemCount; ``` -------------------------------- ### Implement EdgeInsetsGeometry Padding Property Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/padding This snippet shows the declaration of the 'padding' property, which is of type EdgeInsetsGeometry. It is declared as a final variable, indicating it will be assigned a value once and cannot be changed afterwards. ```dart final EdgeInsetsGeometry padding; ``` -------------------------------- ### Declare batchSize Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/batchSize Declares the batchSize property as an optional integer. This property is used exclusively in dynamic mode to define the number of items processed in each batch. The default value is 50. ```dart final int? batchSize; ``` -------------------------------- ### Declare and Implement 'isDynamic' Boolean Property Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/isDynamic This snippet shows the declaration of the 'isDynamic' property as a final boolean. It is intended to be a constant value once initialized, indicating a dynamic state. ```dart bool isDynamic final ``` ```dart final bool isDynamic; ``` -------------------------------- ### Declare fadeInItems Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/fadeInItems Declares the 'fadeInItems' property as a final boolean. This property is intended for use in dynamic mode to control the fade-in animation of items. The default value is true. ```dart final bool fadeInItems; ``` -------------------------------- ### Declare estimatedItemWidth Property in Dart Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/estimatedItemWidth This snippet shows the declaration of the 'estimatedItemWidth' property in Dart. It is a nullable double, indicating that it may or may not hold a value. ```dart final double? estimatedItemWidth; ``` -------------------------------- ### Declare 'spacing' Property in Dart Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/spacing This snippet shows the declaration of a final double variable named 'spacing'. This is a common pattern for defining constants or properties that are set once and not changed. ```dart final double spacing; ``` -------------------------------- ### Implement Row Alignment Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/rowAlignment This snippet shows the declaration of the `rowAlignment` property as a final variable of type `MainAxisAlignment`. This property is used to control the alignment of children within a row along its main axis. ```dart final MainAxisAlignment rowAlignment; ``` -------------------------------- ### Declare estimatedItemHeight Property in Dart Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/estimatedItemHeight This snippet shows the declaration of the nullable double property 'estimatedItemHeight' in Dart. It is marked as 'final', indicating it can only be assigned a value once. ```dart final double? estimatedItemHeight; ``` -------------------------------- ### Flutter itemBuilder Property Declaration Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/itemBuilder This snippet shows the declaration of the `itemBuilder` property in Flutter. It is defined as a function that returns a Widget and accepts a BuildContext and an integer as parameters. This is commonly used in scrollable widgets like ListView to efficiently build items. ```dart final Widget Function(BuildContext, int) itemBuilder; ``` -------------------------------- ### Declare runSpacing Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/runSpacing Declares the 'runSpacing' property as a final double. This property is intended to hold spacing values and is immutable after initialization. ```dart final double runSpacing; ``` -------------------------------- ### Declare cacheExtent Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/cacheExtent This snippet demonstrates the declaration of the 'cacheExtent' property in Dart. It is declared as a final double, indicating it's immutable after initialization and holds a floating-point value. ```dart final double cacheExtent; ``` -------------------------------- ### Declare itemCount Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/itemCount Declares the 'itemCount' property as a final integer. This property is intended to hold a fixed count value and cannot be reassigned after initialization. ```dart int itemCount; final ``` -------------------------------- ### Declare fadeInDuration Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/fadeInDuration This snippet shows the declaration of the fadeInDuration property in Dart. It is a nullable Duration type, intended for use in dynamic modes to control fade-in animations. The default value is 200ms, but this declaration itself does not set the default. ```dart final Duration? fadeInDuration; ``` -------------------------------- ### Declare Scroll Direction Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/scrollDirection This snippet demonstrates the declaration of the 'scrollDirection' property as a final Axis type. It is commonly used in UI frameworks to specify the orientation of scrolling, such as vertical or horizontal. ```dart final Axis scrollDirection; ``` -------------------------------- ### Declare fadeInCurve Property (Dart) Source: https://pub.dev/documentation/lazy_wrap/latest/lazy_wrap/LazyWrap/fadeInCurve Declares the fadeInCurve property, which is an optional Curve object. This property is intended for use in dynamic mode to control the fade-in animation. The default value is Curves.easeOut. ```dart final Curve? fadeInCurve; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.