get static method
Returns the last APIRoot if instantiated.
- If
singleton
istrue
and multiple instances exists throws an StateError.
Implementation
static APIRoot? get({bool singleton = true}) {
if (_instances.isEmpty) {
return null;
} else if (_instances.length == 1) {
return _instances.values.first;
} else if (_instances.length == 2) {
if (singleton) {
throw StateError(
"Multiple APIRoot instances> singleton: $singleton ; length: ${_instances.length} ; names: ${_instances.keys.toList()}");
}
return _instances.values.last;
} else {
return null;
}
}