findStateDefintion method

StateDefinition<State>? findStateDefintion(
  1. Type? stateDefinitionType, {
  2. bool includeChildren = true,
})

recursively searches through the list of nested StateDefinitions for a StateDefinition of type stateDefinitionType;

Implementation

StateDefinition<State>? findStateDefintion(Type? stateDefinitionType,
    {bool includeChildren = true}) {
  StateDefinition? found;
  for (final stateDefinition in childStateDefinitions) {
    if (stateDefinition.stateType == stateDefinitionType) {
      found = stateDefinition;
      break;
    } else {
      if (includeChildren) {
        found = stateDefinition.findStateDefintion(stateDefinitionType);
        if (found != null) {
          break;
        }
      }
    }
  }
  return found;
}