InfiniteCrossScroll class

InfiniteCrossScroll is a Widget that provides an infinite two-dimensional scrolling grid including diagonal scrolling.

It extends the TwoDimensionalScrollView, allowing for both horizontal and vertical scrolling with an arbitrary number of rows and columns. The grid cells are represented by the provided builder function, and the entire widget is backed by a CrossScrollController for efficient scroll control.

Parameters:

  • controller: An optional CrossScrollController that can be provided to control the scrolling behavior. If not provided, a new controller will be created internally.
  • cellSize: The size of each grid cell in the two-dimensional grid.
  • maxRows: The maximum number of rows in the grid.
  • maxColumns: The maximum number of columns in the grid.
  • builder: A function that builds the content of each grid cell based on its location.
  • horizontalScroll: Configuration for horizontal scrolling behavior, with optional parameters like reverse and physics.
  • verticalScroll: Configuration for vertical scrolling behavior, with optional parameters like reverse and physics.
  • diagonalDragBehavior: Defines the diagonal drag behavior, with options like 'free', 'constrained', or 'disabled'.
  • dragStartBehavior: Determines when the drag behavior should start, with options like 'start' or 'down'.
  • keyboardDismissBehavior: Defines the keyboard dismiss behavior for the ScrollView, with options like 'manual' or 'onDrag'.
  • primary: Indicates whether this ScrollView is the primary scroll view.
  • cacheExtent: The maximum number of pixels away from the currently visible pixels that the framework should build children.

Scroll bars

To add scrollbars to InfiniteCrossScroll just wrap it in CrossScrollBar and provide the same controller to both,

Usage Example:

InfiniteCrossScroll(
  cellSize: Size(100, 100),
  maxRows: 20,
  maxColumns: 20,
  builder: (BuildContext context, ChildVicinity vicinity) {
    // Build and return the content for each grid cell based on its position.
    return MyGridCellContent(vicinity);
  },
)
Inheritance

Constructors

InfiniteCrossScroll({CrossScrollController? controller, required int? maxRows, required int? maxColumns, required Size cellSize, required Widget? builder(BuildContext, ChildVicinity), CrossScrollDesign horizontalScroll = const CrossScrollDesign(), CrossScrollDesign verticalScroll = const CrossScrollDesign(), DiagonalDragBehavior diagonalDragBehavior = DiagonalDragBehavior.free, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual, bool? primary, double? cacheExtent, Key? key})
const

Properties

builder Widget? Function(BuildContext, ChildVicinity)
final
cacheExtent double?
final
cellSize Size
final
controller CrossScrollController?
final
diagonalDragBehavior DiagonalDragBehavior
final
dragStartBehavior DragStartBehavior
final
hashCode int
The hash code for this object.
no setterinherited
horizontalScroll CrossScrollDesign
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardDismissBehavior ScrollViewKeyboardDismissBehavior
final
maxColumns int?
final
maxRows int?
final
primary bool?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
verticalScroll CrossScrollDesign
final

Methods

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