SwayzeCellsController<CellDataType extends SwayzeCellData> class

A ChangeNotifier that is in charge of managing the state of all cells in a table and to communicate state changes to its listeners.

There are two ways of modifying it state:

  • From raw cells: Ideally for communicating changes from an external format of cells such as JSON. The changes should be made via putRawCells. The controller constructor also receives a iterable of raw cells. The cells will be parsed to CellDataType via cellParser.

  • From parsed cells: Changes via parsed cells should be made via updateState.

cellsController.updateState((modifier) {
     modifier.putCell(
       TestCellData(
         position: const SwayzeCellPosition(column: 0, row: 0),
         value: 'some new cell',
       ),
     );
});

The parameter on the callback passed to updateState is a CellsModifier.

After each updateState, all listeners of SwayzeCellsController will be notified.

See also:

  • SwayzeTableDataController which controls data regarding table, columns and rows.
  • CellsModifier which is the interface for changes on cells state
  • Cells the internal widget that listen for changes on this state and updates the UI.
Inheritance
Implemented types

Constructors

SwayzeCellsController({required SwayzeController parent, required SwayzeCellsControllerCellParser<CellDataType> cellParser, required Iterable initialRawCells})

Properties

cellMatrixReadOnly → MatrixMapReadOnly<CellDataType>
Access the table of cells in a read only interface.
no setter
cellParser ↔ SwayzeCellsControllerCellParser<CellDataType>
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
parent → SwayzeController
The SwayzeController that has created this sub-controller.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addCellOperationsListener(ValueChanged<List<CellOperation<SwayzeCellData>>> listener) → void
Add a listener that receives the last performed operations that triggered the update.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
override
getNextCoordinate({required IntVector2 originalCoordinate, required AxisDirection direction}) → IntVector2
Given a IntVector2 and a AxisDirection return the next coordinate that is not hidden.
getNextCoordinateInCellsBlock({required IntVector2 originalCoordinate, required AxisDirection direction}) → IntVector2
Given a IntVector2 and a AxisDirection return the next coordinate in the current block of cells.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
putRawCells(Iterable rawCells) → void
Parse all rawCells and save in the state, notifying listeners.
removeCellOperationsListener(ValueChanged<List<CellOperation<SwayzeCellData>>> listener) → void
Remove a closure previously registered on addCellOperationsListener.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() → String
A string representation of this object.
inherited
updateState(void stateUpdate(CellsModifier<CellDataType> modifier)) → void
The way to create changes in the cell state externally.

Operators

operator ==(Object other) → bool
The equality operator.
inherited