setupFromNetworkRequest method
Synchronize Config Data with Server
Implementation
Future<bool> setupFromNetworkRequest(Future<NetworkResult> callback) async {
await _loadFromCache();
if (!shouldSync()) {
return true;
}
try {
NetworkResult networkResult = await callback;
if (networkResult.hasError()) {
return false;
}
if (!networkResult.hasData()) {
return false;
}
Map<String, dynamic> result = networkResult.getData();
_config = result;
await saveConfig();
} catch (e) {
throw e;
}
return true;
}