maybeRefreshCards method
Future<void>
maybeRefreshCards
(- {bool silent: false}
)
Implementation
Future<void> maybeRefreshCards({bool silent = false}) async {
if (creditCardsDirty || status == DataBackendStatus.ERROR) {
try {
await Future.delayed(Duration(milliseconds: 200));
status = DataBackendStatus.LOADING;
if (!silent) {
notifyListeners();
}
creditCards = await fetchCreditCardsFromDatabase();
creditCardsDirty = false;
status = DataBackendStatus.AVAILABLE;
if (!silent) {
notifyListeners();
}
} on CloudFunctionsException catch (cloudFuncError) {
print(cloudFuncError.message);
status = DataBackendStatus.ERROR;
if (!silent) {
notifyListeners();
}
} catch (err) {
print(err.toString());
status = DataBackendStatus.ERROR;
if (!silent) {
notifyListeners();
}
}
} else {
print('Data up to date, no need to refresh');
}
}