### Responsive Grid Constraints Example Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/QUICK-REFERENCE.md Shows how to apply constraints to the number of items per row. ```text minItemsPerRow: 2 → Always at least 2 items maxItemsPerRow: 4 → Never more than 4 items ``` -------------------------------- ### Install responsive_grid_list Package Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/README.md Add the responsive_grid_list package to your pubspec.yaml file to include it in your Flutter project. ```yaml dependencies: responsive_grid_list: ^1.4.1 ``` -------------------------------- ### Responsive Grid Behavior Example Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/QUICK-REFERENCE.md Illustrates how the number of items per row changes based on screen width with a minimum item width of 250px. ```text Screen Width | Items/Row (minItemWidth: 250) 280px | 1 400px | 1 500px | 2 750px | 3 1000px | 4 ``` -------------------------------- ### ResponsiveGridList with ListViewBuilderOptions Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/types.md Example of how to use ListViewBuilderOptions to customize a ResponsiveGridList. This allows for fine-grained control over scrolling physics, padding, and keep-alive behavior. ```dart ResponsiveGridList( minItemWidth: 300, listViewBuilderOptions: ListViewBuilderOptions( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(16), shrinkWrap: true, addAutomaticKeepAlives: true, ), children: [ ...items, ], ) ``` -------------------------------- ### Custom Grid Implementation with ResponsiveGridRow Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_row.md Demonstrates how to create a custom grid layout using ResponsiveGridRow by partitioning items into rows and configuring row properties like spacing and item width. This example shows manual row partitioning for a ListView. ```dart class CustomGrid extends StatelessWidget { final List items; const CustomGrid({required this.items}); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { const itemWidth = 200; const spacing = 16; const itemsPerRow = 3; // Partition items into rows final rows = >[]; for (int i = 0; i < items.length; i += itemsPerRow) { rows.add( items.sublist( i, (i + itemsPerRow).clamp(0, items.length), ), ); } return ListView( children: rows .map( (rowItems) => ResponsiveGridRow( rowItems: rowItems, spacing: spacing, itemWidth: itemWidth, horizontalGridMargin: 24, ), ) .toList(), ); }, ); } } ``` -------------------------------- ### Basic Responsive Grid List Example Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/README.md A simple implementation of ResponsiveGridList displaying a list of cards. It automatically adjusts the number of columns based on the minimum item width. ```dart import 'package:responsive_grid_list/responsive_grid_list.dart'; ResponsiveGridList( minItemWidth: 300, children: List.generate( 50, (index) => Card( child: Center(child: Text('Item $index')), ), ), ) ``` -------------------------------- ### Custom Responsive Grid Implementation Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/abstract_responsive_grid_list.md Extend AbstractResponsiveGridList to create a custom responsive grid. This example shows how to define a new class with specific constructor parameters and override the build method. ```dart class MyCustomResponsiveGrid extends AbstractResponsiveGridList { const MyCustomResponsiveGrid({ required double minItemWidth, required List children, Key? key, int minItemsPerRow = 1, int? maxItemsPerRow, double horizontalGridSpacing = 16, double verticalGridSpacing = 16, double? horizontalGridMargin, double? verticalGridMargin, MainAxisAlignment rowMainAxisAlignment = MainAxisAlignment.start, }) : super( minItemWidth: minItemWidth, minItemsPerRow: minItemsPerRow, maxItemsPerRow: maxItemsPerRow, horizontalGridSpacing: horizontalGridSpacing, verticalGridSpacing: verticalGridSpacing, horizontalGridMargin: horizontalGridMargin, verticalGridMargin: verticalGridMargin, children: children, rowMainAxisAlignment: rowMainAxisAlignment, key: key, ); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { final items = getResponsiveGridListItems(constraints.maxWidth); return SingleChildScrollView( child: Column(children: items), ); }, ); } } ``` -------------------------------- ### Responsive Grid with Custom Scroll Container Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/QUICK-REFERENCE.md Example of using ResponsiveGridListBuilder with a custom scrollable parent like ListView. ```dart ResponsiveGridListBuilder( minItemWidth: 250, gridItems: items, builder: (context, items) => ListView( physics: const BouncingScrollPhysics(), children: items, ), ) ``` -------------------------------- ### ResponsiveSliverGridList with Multiple Slivers Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md Shows an example of using ResponsiveSliverGridList within a CustomScrollView that contains multiple different sliver widgets, including a pinned SliverAppBar and a SliverToBoxAdapter. ```dart CustomScrollView( slivers: [ SliverAppBar( title: const Text('Mixed Slivers'), pinned: true, ), SliverToBoxAdapter( child: Padding( padding: const EdgeInsets.all(16), child: Text('Header Text'), ), ), ResponsiveSliverGridList( minItemWidth: 250, horizontalGridMargin: 16, children: [ ...items, ], ), ], ) ``` -------------------------------- ### Responsive Grid with Animations Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/abstract_responsive_grid_list.md Integrate AbstractResponsiveGridList into a custom widget that uses animations. This example wraps grid items with AnimatedScale for a scaling animation effect. ```dart class AnimatedResponsiveGrid extends AbstractResponsiveGridList { const AnimatedResponsiveGrid({ required double minItemWidth, required List children, Key? key, }) : super( minItemWidth: minItemWidth, children: children, minItemsPerRow: 1, horizontalGridSpacing: 16, verticalGridSpacing: 16, rowMainAxisAlignment: MainAxisAlignment.start, key: key, ); @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { final items = getResponsiveGridListItems(constraints.maxWidth); return ListView.builder( itemCount: items.length, itemBuilder: (context, index) { return AnimatedScale( scale: 1.0, duration: Duration(milliseconds: 300), child: items[index], ); }, ); }, ); } } ``` -------------------------------- ### Responsive Grid with Filtering Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/advanced-patterns.md Combine ResponsiveGridList with state management to create a dynamic grid that updates based on user-selected filters. This example uses FilterChip widgets for category selection. ```dart class FilteredResponsiveGrid extends StatefulWidget { @override State createState() => _FilteredResponsiveGridState(); } class _FilteredResponsiveGridState extends State { String selectedCategory = 'all'; late List allItems; List get filteredItems { if (selectedCategory == 'all') return allItems; return allItems.where((item) => item.category == selectedCategory).toList(); } @override Widget build(BuildContext context) { return Column( children: [ // Category filter buttons SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: categories.map((cat) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: FilterChip( label: Text(cat), selected: selectedCategory == cat, onSelected: (selected) { setState(() { selectedCategory = selected ? cat : 'all'; }); }, ), ); }).toList(), ), ), // Responsive grid with filtered items Expanded( child: ResponsiveGridList( minItemWidth: 250, children: filteredItems .map((item) => ItemCard(item: item)) .toList(), ), ), ], ); } } ``` -------------------------------- ### Responsive Sliver Grid List with Spacing and Margins Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md Implement a ResponsiveSliverGridList within a CustomScrollView, specifying horizontal and vertical spacing and margins for both items and the grid itself. This example also sets a minimum number of items per row. ```dart CustomScrollView( slivers: [ SliverAppBar(title: const Text('Grid with Spacing')), ResponsiveSliverGridList( minItemWidth: 200, horizontalGridSpacing: 20, verticalGridSpacing: 20, horizontalGridMargin: 30, verticalGridMargin: 30, minItemsPerRow: 2, children: [ ...items, ], ), ], ) ``` -------------------------------- ### ResponsiveGridListBuilder with Custom Row Alignment and Minimum Items Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Customize row alignment and minimum items per row using ResponsiveGridListBuilder. This example sets a minimum item width, a minimum of two items per row, and centers the rows within the ListView. ```dart ResponsiveGridListBuilder( minItemWidth: 250, minItemsPerRow: 2, rowMainAxisAlignment: MainAxisAlignment.center, gridItems: [ ...items, ], builder: (context, items) { return ListView( children: items, ); }, ) ``` -------------------------------- ### build Method Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list.md Builds the widget by using LayoutBuilder to measure available width, then calculating the responsive grid and rendering it in a ListView.builder. ```APIDOC ## build Method ### Description Builds the widget by using `LayoutBuilder` to measure available width, then calculating the responsive grid and rendering it in a `ListView.builder()`. ### Parameters #### Path Parameters - **context** (BuildContext) - The build context. ### Returns A `ListView.builder()` containing the responsive grid layout. ``` -------------------------------- ### Import Responsive Grid List Package Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/types.md Import the necessary package to use ResponsiveSliverGridList and its options. ```dart import 'package:responsive_grid_list/responsive_grid_list.dart'; ``` -------------------------------- ### Non-Scrolling Responsive Grid Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/QUICK-REFERENCE.md Example of using ResponsiveGridListBuilder to create a grid that does not scroll, typically within a Column inside a SingleChildScrollView. ```dart ResponsiveGridListBuilder( minItemWidth: 250, gridItems: items, builder: (context, items) => SingleChildScrollView( child: Column(children: items), ), ) ``` -------------------------------- ### Joining Integers with GenericJoin Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/extensions.md Example of using genericJoin to insert a separator between integers in a list. The separator maintains the list's element type. ```dart List numbers = [1, 2, 3, 4, 5]; List joined = numbers.genericJoin(0); // Result: [1, 0, 2, 0, 3, 0, 4, 0, 5] ``` -------------------------------- ### File Organization Structure Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/INDEX.md Illustrates the directory structure of the responsive_grid_list package, showing the location of key documentation files and API references. ```text output/ ├── INDEX.md # This file ├── README.md # Main entry point ├── configuration.md # Constructor options & defaults ├── types.md # Configuration classes ├── extensions.md # List extensions ├── advanced-patterns.md # Advanced usage patterns └── api-reference/ ├── responsive_grid_list.md ├── responsive_sliver_grid_list.md ├── responsive_grid_list_builder.md ├── abstract_responsive_grid_list.md └── responsive_grid_row.md ``` -------------------------------- ### Basic ResponsiveGridList Usage Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list.md Demonstrates basic usage of ResponsiveGridList with a static list of children. Set `minItemWidth` to control item size and responsiveness. ```dart ResponsiveGridList( minItemWidth: 300, children: List.generate( 50, (index) => Card( child: Center(child: Text('Item $index')), ), ), ) ``` -------------------------------- ### ResponsiveGridListBuilder.build Method Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Builds the widget by measuring available width, calculating the responsive grid, and passing the grid items to the builder function. ```APIDOC ## Method: build ### Description Builds the widget by using `LayoutBuilder` to measure available width, calculating the responsive grid, and passing the grid items to the builder function. ### Signature ```dart Widget build(BuildContext context) ``` ### Parameters #### Method Parameters - **context** (BuildContext) - Required - The build context. ### Returns - **Widget** - The widget returned by the `builder` function. ``` -------------------------------- ### ResponsiveGridListBuilder with Wrap (Non-Scrolling Grid) Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Utilize ResponsiveGridListBuilder with a Wrap widget for a non-scrolling, responsive grid layout. This example shows how to configure spacing and use SingleChildScrollView for the parent scroll behavior. ```dart ResponsiveGridListBuilder( minItemWidth: 200, gridItems: [ ...items, ], builder: (context, items) { return SingleChildScrollView( child: Wrap( spacing: 16, runSpacing: 16, children: items.whereType() .expand((row) => row.rowItems) .toList(), ), ); }, ) ``` -------------------------------- ### ResponsiveGridListBuilder Widget Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/GENERATED.txt A flexible builder-based responsive grid widget for custom container implementations. ```APIDOC ## ResponsiveGridListBuilder ### Description A builder-based responsive grid widget that offers flexibility for custom container implementations. It allows for dynamic item generation and layout. ### Constructor ```dart ResponsiveGridListBuilder({ Key? key, required this.itemCount, required this.itemBuilder, this.minSpacing = 8.0, this.minItemsPerRow = 1, this.maxItemsPerRow = 5, this.horizontalGridMargin = 0.0, this.verticalGridMargin = 0.0, this.horizontalInnerMargin = 0.0, this.verticalInnerMargin = 0.0, this.scrollDirection = Axis.vertical, this.physics, this.shrinkWrap = false, this.padding, this.addRepaintBoundaries = true, this.addSemanticBuilder = true, this.addAutomaticKeepAlive = true, this.clipBehavior = Clip.hardEdge, this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.itemExtent, this.semanticChildCount, this.dragStartBehavior = DragStartBehavior.start, this.allowImplicitScrolling = false, this.reverse = false, this.controller, this.primary, this.cacheExtent, this.findChildIndexCallback, }) ``` ### Parameters #### Required Parameters - **itemCount** (int) - The total number of items in the grid. - **itemBuilder** (IndexedWidgetBuilder) - A builder function that creates each item in the grid. #### Optional Parameters - **minSpacing** (double) - Minimum spacing between grid items. Defaults to 8.0. - **minItemsPerRow** (int) - Minimum number of items to display per row. Defaults to 1. - **maxItemsPerRow** (int) - Maximum number of items to display per row. Defaults to 5. - **horizontalGridMargin** (double) - Margin on the left and right sides of the grid. Defaults to 0.0. - **verticalGridMargin** (double) - Margin on the top and bottom sides of the grid. Defaults to 0.0. - **horizontalInnerMargin** (double) - Inner horizontal spacing between items. Defaults to 0.0. - **verticalInnerMargin** (double) - Inner vertical spacing between items. Defaults to 0.0. - **scrollDirection** (Axis) - The axis along which the scroll view scrolls. Defaults to Axis.vertical. - **physics** (ScrollPhysics) - How the scroll view scrolls. - **shrinkWrap** (bool) - Whether the scroll view should the shrink wrap its content. - **padding** (EdgeInsetsGeometry) - Padding around the scroll view. - **addRepaintBoundaries** (bool) - Whether to wrap each child in a RepaintBoundary. - **addSemanticBuilder** (bool) - Whether to wrap each child in a Semantics widget. - **addAutomaticKeepAlive** (bool) - Whether to wrap each child in an AutomaticKeepAlive widget. - **clipBehavior** (Clip) - How to clip the content of the scroll view. - **keyboardDismissBehavior** (ScrollViewKeyboardDismissBehavior) - Determines how keyboard visibility changes. - **restorationId** (String) - Restoration ID for the scroll view. - **itemExtent** (double) - The extent of each item. - **semanticChildCount** (int) - The number of semantic children. - **dragStartBehavior** (DragStartBehavior) - Defines the drag behavior. - **allowImplicitScrolling** (bool) - Whether to allow implicit scrolling. - **reverse** (bool) - Whether the scroll view scrolls in the reverse direction. - **controller** (ScrollController) - An object that can be used to control the position to scroll to. - **primary** (bool) - Whether this is the primary scroll view. - **cacheExtent** (double) - The number of pixels to cache ahead of time. - **findChildIndexCallback** (NullableValidIndexCallback) - Callback to find the index of a child. ### Methods This widget is designed for custom container implementations and relies on its builder pattern. It does not expose public methods for direct invocation beyond standard Flutter widget lifecycle methods. ``` -------------------------------- ### Main Package Export Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/README.md Imports all public types from the main responsive_grid_list package. This includes widgets like ResponsiveGridList and ResponsiveSliverGridList, the base class AbstractResponsiveGridList, and configuration classes. ```dart import 'package:responsive_grid_list/responsive_grid_list.dart'; // Widgets ResponsiveGridList ResponsiveSliverGridList ResponsiveGridListBuilder ResponsiveGridRow // Base class AbstractResponsiveGridList // Configuration classes ListViewBuilderOptions SliverChildBuilderDelegateOptions ``` -------------------------------- ### ResponsiveGridList Widget Configuration Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/README.md Configure a responsive grid list using ListView.builder(). Adjust spacing, margins, and item constraints for different screen sizes. ```dart ResponsiveGridList( horizontalGridSpacing: 16, // Horizontal space between grid items verticalGridSpacing: 16, // Vertical space between grid items horizontalGridMargin: 50, // Horizontal space around the grid verticalGridMargin: 50, // Vertical space around the grid minItemWidth: 300, // The minimum item width (can be smaller, if the layout constraints are smaller) minItemsPerRow: 2, // The minimum items to show in a single row. Takes precedence over minItemWidth maxItemsPerRow: 5, // The maximum items to show in a single row. Can be useful on large screens listViewBuilderOptions: ListViewBuilderOptions(), // Options that are getting passed to the ListView.builder() function children: [...], // The list of widgets in the list ); ``` -------------------------------- ### Animated Grid Transitions with AnimatedSwitcher Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/advanced-patterns.md Implement smooth animations for grid recalculations on size or orientation changes. Use AnimatedSwitcher and WidgetsBindingObserver to manage transitions. ```dart class AnimatedResponsiveGrid extends StatefulWidget { @override State createState() => _AnimatedResponsiveGridState(); } class _AnimatedResponsiveGridState extends State with WidgetsBindingObserver { @override void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); } @override void didChangeMetrics() { setState(() {}); // Rebuild on orientation/size change } @override Widget build(BuildContext context) { return AnimatedSwitcher( duration: Duration(milliseconds: 300), child: ResponsiveGridList( key: ValueKey(MediaQuery.of(context).size.width), minItemWidth: 250, children: items .map((item) => AnimatedScale( scale: 1.0, duration: Duration(milliseconds: 300), child: ItemCard(item: item), )) .toList(), ), ); } @override void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } } ``` -------------------------------- ### Responsive Grid List with ListView.builder Options Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list.md Configure advanced `ListView.builder` properties like physics, padding, and `addAutomaticKeepAlives` using `listViewBuilderOptions`. This allows fine-grained control over the scrolling behavior and performance of the grid. ```dart ResponsiveGridList( minItemWidth: 300, listViewBuilderOptions: ListViewBuilderOptions( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(16), addAutomaticKeepAlives: true, ), children: [ ...items, ], ) ``` -------------------------------- ### ResponsiveSliverGridList Constructor Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md The ResponsiveSliverGridList widget constructor allows for the creation of a responsive grid within a sliver context. It requires minimum item width and a list of children, with several optional parameters to control layout, spacing, and alignment. ```APIDOC ## ResponsiveSliverGridList ### Description A Flutter widget that creates a responsive grid layout using `SliverList` with a `SliverChildBuilderDelegate` internally. Use this when integrating responsive grids into a sliver-based layout like `CustomScrollView`. ### Constructor Parameters - **minItemWidth** (double) - Required - The minimum width of each grid item. Items will be smaller if layout constraints are smaller. Must be greater than 0. - **children** (List) - Required - The list of widgets to display in the grid. - **key** (Key) - Optional - An optional widget key. - **minItemsPerRow** (int) - Optional - Minimum number of items to display per row. Takes precedence over `minItemWidth` and allows items to be smaller if needed to fit this many items. Defaults to 1. - **maxItemsPerRow** (int?) - Optional - Maximum number of items per row. Useful for limiting columns on large screens. When set, items stretch to fill width when the maximum is reached. - **horizontalGridSpacing** (double) - Optional - The horizontal spacing between adjacent grid items in a row. Defaults to 16. - **verticalGridSpacing** (double) - Optional - The vertical spacing between rows of grid items. Defaults to 16. - **horizontalGridMargin** (double?) - Optional - Horizontal margin around the entire grid (applied on both left and right). - **verticalGridMargin** (double?) - Optional - Vertical margin around the entire grid (applied on both top and bottom). - **rowMainAxisAlignment** (MainAxisAlignment) - Optional - How items are aligned along the main axis within each row. Defaults to `MainAxisAlignment.start`. - **sliverChildBuilderDelegateOptions** (SliverChildBuilderDelegateOptions?) - Optional - An object containing optional SliverChildBuilderDelegate parameters. See [SliverChildBuilderDelegateOptions](../types.md#sliverchildbuilderdelegateoptions). ``` -------------------------------- ### Common ResponsiveGridList Parameters Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/INDEX.md Key parameters for configuring the ResponsiveGridList widget to achieve responsive item layouts. ```dart ResponsiveGridList( minItemWidth: 300, // Main responsive parameter minItemsPerRow: 1, // Minimum columns maxItemsPerRow: 6, // Maximum columns horizontalGridSpacing: 16, // Item spacing verticalGridSpacing: 16, // Row spacing horizontalGridMargin: 16, // Grid padding children: [...], // Items to display ) ``` -------------------------------- ### ResponsiveGridListBuilder Usage with ListView Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Demonstrates how to use ResponsiveGridListBuilder with a ListView as the builder's return widget. Configure minItemWidth and provide a list of grid items. ```dart ResponsiveGridListBuilder( minItemWidth: 300, gridItems: List.generate( 50, (index) => Card( child: Center(child: Text('Item $index')), ), ), builder: (context, items) { return ListView( children: items, ); }, ) ``` -------------------------------- ### ResponsiveGridList Constructor Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list.md Initializes a new instance of the ResponsiveGridList widget. This widget creates a responsive grid layout that efficiently renders a list of children using ListView.builder. ```APIDOC ## ResponsiveGridList Constructor ### Description Initializes a new instance of the ResponsiveGridList widget. This widget creates a responsive grid layout that efficiently renders a list of children using ListView.builder. ### Parameters #### Required Parameters - **minItemWidth** (double) - The minimum width of each grid item. Items will be smaller if layout constraints are smaller. Must be greater than 0. - **children** (List) - The list of widgets to display in the grid. #### Optional Parameters - **key** (Key) - An optional widget key. - **minItemsPerRow** (int) - Minimum number of items to display per row. Takes precedence over `minItemWidth` and allows items to be smaller if needed to fit this many items. Default: 1. - **maxItemsPerRow** (int) - Maximum number of items per row. Useful for limiting columns on large screens. When set, items stretch to fill width when the maximum is reached. - **horizontalGridSpacing** (double) - The horizontal spacing between adjacent grid items in a row. Default: 16. - **verticalGridSpacing** (double) - The vertical spacing between rows of grid items. Default: 16. - **horizontalGridMargin** (double) - Horizontal margin around the entire grid (applied on both left and right). - **verticalGridMargin** (double) - Vertical margin around the entire grid (applied on both top and bottom). - **rowMainAxisAlignment** (MainAxisAlignment) - How items are aligned along the main axis within each row. Default: MainAxisAlignment.start. - **shrinkWrap** (bool) - **Deprecated**: Use `listViewBuilderOptions.shrinkWrap` instead. Whether the ListView should shrink-wrap its contents. Default: false. - **listViewBuilderOptions** (ListViewBuilderOptions) - An object containing optional ListView.builder parameters. See [ListViewBuilderOptions](../types.md#listviewbuilderoptions). ### Return Type Returns a `Widget` that renders a responsive grid list wrapped in a `ListView.builder()`. ``` -------------------------------- ### ListViewBuilderOptions Configuration Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/QUICK-REFERENCE.md Configure the underlying ListView.builder() parameters when using ResponsiveGridList. Available properties include physics, padding, and cacheExtent. ```dart ListViewBuilderOptions( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(16), shrinkWrap: false, cacheExtent: 256, addAutomaticKeepAlives: true, ) ``` -------------------------------- ### Basic ResponsiveGridRow Usage Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_row.md Demonstrates the fundamental usage of ResponsiveGridRow with a list of widgets, spacing, and a defined item width. This is typical for internal use within a grid list. ```dart ResponsiveGridRow( rowItems: [ Card(child: Text('Item 1')), Card(child: Text('Item 2')), Card(child: Text('Item 3')), ], spacing: 16, itemWidth: 200, ) ``` -------------------------------- ### ResponsiveGridRow.build Method Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_row.md Builds the widget by arranging the row items with specified widths, spacing, margins, and alignment, ensuring consistent height across all items. ```APIDOC ## build ### Description Builds the widget by: wrapping each `rowItem` in a `SizedBox` of width `itemWidth`, joining the sized items with `SizedBox` spacers of width `spacing`, adding horizontal margins (if specified) as `SizedBox` padding items on both sides, and rendering everything in an `IntrinsicHeight` → `Row` with `CrossAxisAlignment.stretch` to make all items the height of the tallest item. ### Method ```dart Widget build(BuildContext context) ``` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Response #### Success Response * **Widget** - A `Widget` containing the row of items with proper spacing and sizing. ``` -------------------------------- ### ResponsiveGridListBuilder Constructor Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Initializes a ResponsiveGridListBuilder widget. It calculates a responsive grid layout and passes the arranged items to a builder function for custom rendering. ```APIDOC ## Class: ResponsiveGridListBuilder ### Description A Flutter widget that creates a responsive grid layout and provides the grid items as a list to a custom builder function. Use this when you need full control over the list container (ListView, Column, etc.). ### Constructor ```dart const ResponsiveGridListBuilder({ required double minItemWidth, required List gridItems, required Widget Function(BuildContext context, List items) builder, Key? key, int minItemsPerRow = 1, int? maxItemsPerRow, double horizontalGridSpacing = 16, double verticalGridSpacing = 16, double? horizontalGridMargin, double? verticalGridMargin, MainAxisAlignment rowMainAxisAlignment = MainAxisAlignment.start, }); ### Parameters #### Constructor Parameters - **minItemWidth** (double) - Required - The minimum width of each grid item. Items will be smaller if layout constraints are smaller. Must be greater than 0. - **gridItems** (List) - Required - The list of widgets to display in the grid. Passed to the parent constructor as `children`. - **builder** (Widget Function(BuildContext, List)) - Required - A callback function that receives the responsive grid items and returns a widget. Typically returns a ListView, Column, or other list-like widget. - **key** (Key) - Optional - An optional widget key. - **minItemsPerRow** (int) - Optional - Minimum number of items to display per row. Takes precedence over `minItemWidth` and allows items to be smaller if needed to fit this many items. Defaults to 1. - **maxItemsPerRow** (int) - Optional - Maximum number of items per row. Useful for limiting columns on large screens. When set, items stretch to fill width when the maximum is reached. - **horizontalGridSpacing** (double) - Optional - The horizontal spacing between adjacent grid items in a row. Defaults to 16. - **verticalGridSpacing** (double) - Optional - The vertical spacing between rows of grid items. Defaults to 16. - **horizontalGridMargin** (double) - Optional - Horizontal margin around the entire grid (applied on both left and right). - **verticalGridMargin** (double) - Optional - Vertical margin around the entire grid (applied on both top and bottom). - **rowMainAxisAlignment** (MainAxisAlignment) - Optional - How items are aligned along the main axis within each row. Defaults to `MainAxisAlignment.start`. ### Return Type Returns a `Widget` that calls the provided `builder` function with the responsive grid items. ``` -------------------------------- ### ResponsiveGridList with ListView.builder Options Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/configuration.md Configure the underlying ListView.builder for ResponsiveGridList. Use this to customize scroll physics, padding, and item caching. ```dart ResponsiveGridList( minItemWidth: 300, listViewBuilderOptions: ListViewBuilderOptions( physics: const BouncingScrollPhysics(), // Bouncy scroll physics padding: const EdgeInsets.all(16), // Padding around the list shrinkWrap: false, // Don't shrink-wrap addAutomaticKeepAlives: true, // Keep alive state cacheExtent: 256, // Cache off-screen items ), children: [...], ) ``` -------------------------------- ### Custom Responsive Grid List Implementation Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/README.md Extend AbstractResponsiveGridList to create a custom responsive grid. Use getResponsiveGridListItems with constraints.maxWidth to generate grid items within a LayoutBuilder. ```dart class MyResponsiveGridList extends AbstractResponsiveGridList{ /// Constructor etc... [...] @override Widget build(BuildContext context) { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { // The abstract class has a function to generate the grid from // the constructor's paramters and the layout constraints max width var items = getResponsiveGridListItems(constraints.maxWidth); return [...] }, ); } } ``` -------------------------------- ### Basic Widget Spacing with GenericJoin Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/extensions.md Demonstrates using genericJoin to add spacing between a list of Widgets. The result can be directly used in a Column. ```dart List items = [ Text('Item 1'), Text('Item 2'), Text('Item 3'), ]; List spaced = items.genericJoin(SizedBox(width: 16)); // Result: [Text('Item 1'), SizedBox(width: 16), Text('Item 2'), SizedBox(width: 16), Text('Item 3')], Column(children: spaced) // Items with 16px spacing ``` -------------------------------- ### ResponsiveGridList Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/README.md A Responsive Grid List widget that uses `ListView.builder()` internally for performance with large lists. ```APIDOC ## ResponsiveGridList ### Description A Responsive Grid List which uses `ListView.builder()` internally. ### Widget Signature ```dart ResponsiveGridList({ required List children, double? horizontalGridSpacing, double? verticalGridSpacing, double? horizontalGridMargin, double? verticalGridMargin, double? minItemWidth, int? minItemsPerRow, int? maxItemsPerRow, ListViewBuilderOptions? listViewBuilderOptions, }) ``` ### Parameters #### Widget Properties - **children** (List) - Required - The list of widgets to display in the grid. - **horizontalGridSpacing** (double) - Optional - Horizontal space between grid items. - **verticalGridSpacing** (double) - Optional - Vertical space between grid items. - **horizontalGridMargin** (double) - Optional - Horizontal space around the grid. - **verticalGridMargin** (double) - Optional - Vertical space around the grid. - **minItemWidth** (double) - Optional - The minimum item width. Can be smaller if layout constraints are smaller. - **minItemsPerRow** (int) - Optional - The minimum items to show in a single row. Takes precedence over `minItemWidth`. - **maxItemsPerRow** (int) - Optional - The maximum items to show in a single row. Can be useful on large screens. - **listViewBuilderOptions** (ListViewBuilderOptions) - Optional - Options that are passed to the `ListView.builder()` function. ``` -------------------------------- ### ResponsiveSliverGridList Build Method Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md The build method for ResponsiveSliverGridList, responsible for creating the SliverList with a SliverChildBuilderDelegate based on layout constraints. ```dart Widget build(BuildContext context) { // Builds the widget using SliverLayoutBuilder to measure available width, then calculating the responsive grid and rendering it as a SliverList with a SliverChildBuilderDelegate. } ``` -------------------------------- ### ListViewBuilderOptions Class Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/GENERATED.txt Configuration class for ListView.builder options used in responsive grids. ```APIDOC ## ListViewBuilderOptions ### Description This class encapsulates various options and parameters that can be passed to a ListView.builder, allowing for fine-grained control over its behavior within the responsive grid context. ### Constructor ```dart ListViewBuilderOptions({ this.scrollDirection = Axis.vertical, this.physics, this.shrinkWrap = false, this.padding, this.addRepaintBoundaries = true, this.addSemanticBuilder = true, this.addAutomaticKeepAlive = true, this.clipBehavior = Clip.hardEdge, this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, this.restorationId, this.itemExtent, this.semanticChildCount, this.dragStartBehavior = DragStartBehavior.start, this.allowImplicitScrolling = false, this.reverse = false, this.controller, this.primary, this.cacheExtent, this.findChildIndexCallback, }) ``` ### Parameters - **scrollDirection** (Axis) - The axis along which the scroll view scrolls. Defaults to Axis.vertical. - **physics** (ScrollPhysics) - How the scroll view scrolls. - **shrinkWrap** (bool) - Whether the scroll view should the shrink wrap its content. Defaults to false. - **padding** (EdgeInsetsGeometry) - Padding around the scroll view. - **addRepaintBoundaries** (bool) - Whether to wrap each child in a RepaintBoundary. Defaults to true. - **addSemanticBuilder** (bool) - Whether to wrap each child in a Semantics widget. Defaults to true. - **addAutomaticKeepAlive** (bool) - Whether to wrap each child in an AutomaticKeepAlive widget. Defaults to true. - **clipBehavior** (Clip) - How to clip the content of the scroll view. Defaults to Clip.hardEdge. - **keyboardDismissBehavior** (ScrollViewKeyboardDismissBehavior) - Determines how keyboard visibility changes. Defaults to ScrollViewKeyboardDismissBehavior.manual. - **restorationId** (String) - Restoration ID for the scroll view. - **itemExtent** (double) - The extent of each item. - **semanticChildCount** (int) - The number of semantic children. - **dragStartBehavior** (DragStartBehavior) - Defines the drag behavior. Defaults to DragStartBehavior.start. - **allowImplicitScrolling** (bool) - Whether to allow implicit scrolling. Defaults to false. - **reverse** (bool) - Whether the scroll view scrolls in the reverse direction. Defaults to false. - **controller** (ScrollController) - An object that can be used to control the position to scroll to. - **primary** (bool) - Whether this is the primary scroll view. - **cacheExtent** (double) - The number of pixels to cache ahead of time. - **findChildIndexCallback** (NullableValidIndexCallback) - Callback to find the index of a child. ### Methods This class is a data container for configuration options and does not have public methods for direct invocation. ``` -------------------------------- ### build Method Signature (Abstract) Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/abstract_responsive_grid_list.md Abstract method signature that must be implemented by subclasses to define how grid items are rendered. ```dart Widget build(BuildContext context) ``` -------------------------------- ### ResponsiveGridListBuilder Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/README.md A Responsive Grid List builder that allows integration with any list or column widget. ```APIDOC ## ResponsiveGridListBuilder ### Description A Responsive Grid List which offers a `builder` in which every List or Column can be used with this package. ### Widget Signature ```dart ResponsiveGridListBuilder({ required List gridItems, required Widget Function(BuildContext context, List items) builder, double? horizontalGridSpacing, double? verticalGridSpacing, double? horizontalGridMargin, double? verticalGridMargin, double? minItemWidth, int? minItemsPerRow, int? maxItemsPerRow, }) ``` ### Parameters #### Widget Properties - **gridItems** (List) - Required - The list of widgets to be arranged in the grid. - **builder** (Widget Function(BuildContext context, List items)) - Required - A builder function that receives the build context and the arranged grid items, allowing you to construct your list or column. - **horizontalGridSpacing** (double) - Optional - Horizontal space between grid items. - **verticalGridSpacing** (double) - Optional - Vertical space between grid items. - **horizontalGridMargin** (double) - Optional - Horizontal space around the grid. - **verticalGridMargin** (double) - Optional - Vertical space around the grid. - **minItemWidth** (double) - Optional - The minimum item width. Can be smaller if layout constraints are smaller. - **minItemsPerRow** (int) - Optional - The minimum items to show in a single row. Takes precedence over `minItemWidth`. - **maxItemsPerRow** (int) - Optional - The maximum items to show in a single row. Can be useful on large screens. ``` -------------------------------- ### Basic Responsive Grid List Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/configuration.md A simple ResponsiveGridList with a minimum item width. Other options default to single column, 16px spacing, and no margins. ```dart ResponsiveGridList( minItemWidth: 300, children: List.generate(50, (i) => Card(child: Text('Item $i'))), ) ``` -------------------------------- ### ResponsiveGridListBuilder Widget Configuration Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/README.md Utilize the builder pattern for custom list or column implementations with responsive grid layout. Define grid items and a builder function. ```dart ResponsiveGridListBuilder( horizontalGridSpacing: 16, // Horizontal space between grid items verticalGridSpacing: 16, // Vertical space between grid items horizontalGridMargin: 50, // Horizontal space around the grid verticalGridMargin: 50, // Vertical space around the grid minItemWidth: 300, // The minimum item width (can be smaller, if the layout constraints are smaller) minItemsPerRow: 2, // The minimum items to show in a single row. Takes precedence over minItemWidth maxItemsPerRow: 5, // The maximum items to show in a single row. Can be useful on large screens gridItems: [...], // The list of widgets in the grid builder: (context, items) { // Place to build a List or Column to access all properties. // Set [items] as children attribute for example. } ); ``` -------------------------------- ### ResponsiveGridListBuilder with Custom Padding and Physics Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_list_builder.md Configure ResponsiveGridListBuilder with custom padding and scroll physics by embedding it within a ListView. This snippet demonstrates setting specific item widths, spacing, and margins. ```dart ResponsiveGridListBuilder( minItemWidth: 200, horizontalGridSpacing: 20, verticalGridSpacing: 20, horizontalGridMargin: 30, gridItems: [ ...items, ], builder: (context, items) { return ListView( physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(16), children: items, ); }, ) ``` -------------------------------- ### Basic Usage in CustomScrollView Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md Demonstrates how to integrate ResponsiveSliverGridList into a CustomScrollView, placing it alongside other slivers like SliverAppBar. ```dart CustomScrollView( slivers: [ SliverAppBar( title: Text('Responsive Grid'), ), ResponsiveSliverGridList( minItemWidth: 300, children: List.generate( 50, (index) => Card( child: Center(child: Text('Item $index')), ), ), ), ], ) ``` -------------------------------- ### ResponsiveSliverGridList.build Method Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_sliver_grid_list.md The build method for ResponsiveSliverGridList constructs the sliver widget. It measures the available width and renders the grid items using a SliverList and SliverChildBuilderDelegate. ```APIDOC ## build ### Description Builds the widget using `SliverLayoutBuilder` to measure available width, then calculating the responsive grid and rendering it as a `SliverList` with a `SliverChildBuilderDelegate`. ### Method `Widget build(BuildContext context)` ### Parameters - **context** (BuildContext) - Required - The build context. ### Returns A `SliverList` containing the responsive grid layout. ``` -------------------------------- ### Lazy Item Building with ResponsiveGridListBuilder Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/advanced-patterns.md For very large datasets, use ResponsiveGridListBuilder with a builder function. This pattern allows for lazy item building, ensuring that only visible items are constructed, which is more efficient than pre-generating all items. ```dart ResponsiveGridListBuilder( minItemWidth: 250, gridItems: [], // Empty initially builder: (context, items) { // Only build visible items return ListView.builder( itemCount: totalItemCount, itemBuilder: (context, index) { return ItemCard(index: index); }, ); }, ) ``` -------------------------------- ### ResponsiveGridRow Constructor Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/api-reference/responsive_grid_row.md Defines a single row for a responsive grid. It takes a list of widgets, spacing, and item width as required parameters, along with optional alignment and margin settings. ```APIDOC ## ResponsiveGridRow ### Description A Flutter widget that renders a single row of responsive grid items with consistent widths and proper spacing. It ensures all items in the row have the same width and applies consistent spacing between them. The row height is determined by the tallest item in the row. ### Constructor ```dart const ResponsiveGridRow({ required List rowItems, required double spacing, required double itemWidth, Key? key, double? horizontalGridMargin, MainAxisAlignment rowMainAxisAlignment = MainAxisAlignment.start, }); ``` ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **rowItems** (List) - Required - The widgets to display in this row. * **spacing** (double) - Required - The horizontal spacing between items in the row. * **itemWidth** (double) - Required - The width to apply to each item in the row. All items will have this width. * **key** (Key) - Optional - An optional widget key. * **horizontalGridMargin** (double?) - Optional - Horizontal margin around the row (applied on both left and right). * **rowMainAxisAlignment** (MainAxisAlignment) - Optional - How items are aligned along the horizontal axis within the row. Defaults to `MainAxisAlignment.start`. ``` -------------------------------- ### ResponsiveSliverGridList with Sliver Delegate Options Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/configuration.md Configure the underlying SliverChildBuilderDelegate for ResponsiveSliverGridList. This allows for optimization of repaints and accessibility. ```dart ResponsiveSliverGridList( minItemWidth: 300, sliverChildBuilderDelegateOptions: SliverChildBuilderDelegateOptions( addAutomaticKeepAlives: true, // Preserve state addRepaintBoundaries: true, // Optimize repaints addSemanticIndexes: true, // Accessibility support ), children: [...], ) ``` -------------------------------- ### Basic Usage of SliverChildBuilderDelegateOptions Source: https://github.com/hauketoenjes/responsive_grid_list/blob/main/_autodocs/types.md Configure basic options like automatic keep-alives and repaint boundaries for the sliver child builder delegate. ```dart ResponsiveSliverGridList( minItemWidth: 300, sliverChildBuilderDelegateOptions: SliverChildBuilderDelegateOptions( addAutomaticKeepAlives: true, addRepaintBoundaries: true, semanticIndexOffset: 0, ), children: [ ...items, ], ) ```