load method
Loads the record.
keepPrevious holds the currently-shown record while the new one loads,
and holds it through a failure too — a refresh that fails must not cost
the user the data they were already reading. Default false so a first
load, or a move to a different record, never shows the previous one's
values under the new one's title.
Implementation
Future<void> load({bool keepPrevious = false}) async {
_status = LoadStatus.loading;
_errorMessage = null;
_isUnauthenticated = false;
if (!keepPrevious) _record = null;
notifyListeners();
try {
_record = await _source.record(resource.key, id);
_status = LoadStatus.success;
} catch (e) {
if (e is FilamentTransportException && e.statusCode == 401) {
_isUnauthenticated = true;
}
_errorMessage = messageOf(e);
_status = LoadStatus.failure;
}
notifyListeners();
}