controllerByType<U extends StateXController> method

  1. @override
U? controllerByType<U extends StateXController>()
inherited

Retrieve a StateXController by type.

Implementation

@override
U? controllerByType<U extends StateXController>() {
  U? controller;

  // Take a copy of the types
  final temp = Map.of(_mapControllerTypes);

  // and remove all not of the specified type
  temp.removeWhere((key, value) => value != U);

  // There can only be one instance of a particular type returned.
  if (temp.length == 1) {
    controller = _mapControllerById[temp.keys.first] as U?;
  }
  return controller;
}