getAndInit static method
Implementation
static Future<ARSDataAPI> getAndInit() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final userName = prefs.getString("userName");
final password = prefs.getString("password");
final address = prefs.getString("address");
final port = prefs.getString("port");
if (userName == null ||
password == null ||
address == null ||
port == null) {
if (userName == null) {
logger.error("userName is not set!!");
}
if (password == null) {
logger.error("password is not set!!");
}
if (address == null) {
logger.error("address is not set!!");
}
if (port == null) {
logger.error("port is not set!!");
}
throw Exception("Unable to initialize ARSDataAPI");
}
final api = ARSDataAPI(
userName: userName,
password: password,
address: address,
port: port,
);
await api._authenticate();
return api;
}