SpannableGrid class

A grid widget that allows its items to span columns and rows and supports editing.

Widget layouts its children (defined in cells) in a grid of fixed columns and rows. The gaps between grid cells is defined by optional spacing parameter. The SpannableGrid is sized to fit its parent widget width.

The widget supports editing mode in which user can move selected cell to available places withing the grid. User enter the editing mode by long press on the cell. In the editing mode the editing cell is highlighted while other cells are faded. All grid structure becomes visible. User exit the editing mode by click on editing cell. Updated SpannableGridCellData object is returned in the onCellChanged callback.

SpannableGrid(
  columns: 4,
  rows: 4,
  cells: cells,
  spacing: 2.0,
  onCellChanged: (cell) { print('Cell ${cell.id} changed'); },
),
Inheritance

Constructors

SpannableGrid({Key? key, required List<SpannableGridCellData> cells, required int columns, Widget? emptyCellView, double? rowHeight, required int rows, bool showGrid = false, double spacing = 0.0, dynamic onCellChanged(SpannableGridCellData?)?, Color editingGridColor = Colors.black12, bool editingOnLongPress = true, Decoration? editingCellDecoration})

Properties

cells List<SpannableGridCellData>
Items data
final
columns int
Number of columns
final
editingCellDecoration Decoration?
Decoration to highlight the editing cell in the editing mode.
final
editingGridColor Color
This color is used to display available grid cells in the editing mode.
final
editingOnLongPress bool
Allows editing by long press on grid item
final
emptyCellView Widget?
A widget to display in empty cells. Also it is used as a background for all cells in the editing mode. If it is not set, the empty cell appears as a grey (Colors.black12) square.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onCellChanged → (dynamic Function(SpannableGridCellData?)?)
A callback, that called when a cell position is changed by the user
final
rowHeight double?
The height of grid rows
final
rows int
Number of rows
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showGrid bool
When set to 'true', the grid structure is always visible. emptyCellView is used to display empty cells.
final
spacing double
Space between cells
final

Methods

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