get static method

APIRoot? get({
  1. bool singleton = true,
})

Returns the last APIRoot if instantiated.

  • If singleton is true 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;
  }
}