getState<T extends CellState<StatefulCell>> static method

T getState<T extends CellState<StatefulCell>>(
  1. dynamic key,
  2. T create()
)

Get the state for the cell identified by key.

If key is null, create is called to create a new CellState which is returned.

If key is non-null and it identifies a cell with an existing state, the existing state is returned. If there is no existing state a new state is created using create, the state is associated with key so that future calls to getState with the same key return the same state, and the state is returned.

Implementation

static T getState<T extends CellState>(key, T Function() create) {
  return key != null
      ? _cellStates.putIfAbsent(key, create) as T
      : create();
}