add method

StatesMeta? add(
  1. String state
)
override

Adds a new state to the state machine.

@param newState The new state to add. @return True is teh state was added, false if it was not.

Implementation

StatesMeta? add(String state) {
  // print('< States -> add: ${state}');
  if (locked) return null;

  /// can't have duplicate states
  if (has(state: state)) return null;
  final stateMeta = StatesMeta(state);
  _metas.add(stateMeta);

  /// if no states exist set current state to first state
  if (_metas.length == 1) {
    _currentStateMeta = stateMeta;
    // print('<< _currentStateMeta: ${stateMeta.name}');
  }
  return stateMeta;
}