getByType<A extends APIRoot> static method
Returns an APIRoot instance by type
.
Implementation
static A? getByType<A extends APIRoot>(
{Type? type, bool lastAsDefault = false}) {
type ??= A;
var apiRoot =
_instances.values.firstWhereOrNull((e) => e.runtimeType == type);
if (apiRoot != null) return apiRoot as A;
apiRoot = _instances.values.firstWhereOrNull((e) => e is A);
if (apiRoot != null) return apiRoot as A;
return lastAsDefault ? get(singleton: false) as A? : null;
}