NakamaRestApiClient.init constructor
NakamaRestApiClient.init({})
Either inits and returns a new instance of NakamaRestApiClient or returns a already initialized one.
Implementation
factory NakamaRestApiClient.init({
String? host,
String? serverKey,
String key = _kDefaultAppKey,
int port = 7350,
bool ssl = false,
}) {
if (_clients.containsKey(key)) {
return _clients[key]!;
}
// Not yet initialized -> check if we've got all parameters to do so
if (host == null || serverKey == null) {
throw Exception(
'Not yet initialized, need parameters [host] and [serverKey] to initialize.',
);
}
// Create a new instance of this with given parameters.
return _clients[key] = NakamaRestApiClient._(
host: host,
port: port,
serverKey: serverKey,
ssl: ssl,
);
}