maybeRefreshCreditCardTemplates method
Future<void>
maybeRefreshCreditCardTemplates
(- {bool silent: false}
)
Implementation
Future<void> maybeRefreshCreditCardTemplates({bool silent = false}) async {
if (creditCardTempaltesDirty || status == DataBackendStatus.ERROR) {
try {
await Future.delayed(Duration(milliseconds: 200));
status = DataBackendStatus.LOADING;
if (!silent) {
notifyListeners();
}
creditCardTemplates = await getLocalCreditCardTemplates();
await Duration(milliseconds: 200);
creditCardTempaltesDirty = false;
status = DataBackendStatus.AVAILABLE;
if (!silent) {
notifyListeners();
}
} catch (err) {
print(err.toString());
creditCardTemplates = [];
status = DataBackendStatus.ERROR;
if (!silent) {
notifyListeners();
}
}
} else {
print('Tempalte up-to-date.');
}
}