build method
Implementation
StateDefinition build() {
if (_stateDefinition.isLeaf) {
_initialState = _stateDefinition.stateType;
return _stateDefinition;
} else {
/// If no initial state then the first state is the initial state.
if (_initialState == _UndefinedInitialState &&
_stateDefinition.childStateDefinitions.isNotEmpty) {
_initialState = _stateDefinition.childStateDefinitions[0].stateType;
}
assert(_initialState != _UndefinedInitialState, 'unexpeted state');
final sd = _stateDefinition.findStateDefintion(_initialState,
includeChildren: false);
if (sd == null) {
throw InvalidInitialStateException(
'''The initialState $_initialState MUST be a child state of ${_stateDefinition.stateType}.''');
}
_stateDefinition.initialState = _initialState;
return _stateDefinition;
}
}