refresh method
Refresh the Injected state. Refreshing the state means reinitialize it and reinvoke its creation function and notify its listeners.
If the state is persisted using PersistState, the state is deleted from the store and the new recalculated state is stored instead.
If the Injected model has Injected.inherited injected models, they will be refreshed also.
Implementation
@override
Future<T?> refresh({String? infoMessage}) async {
if (inheritedInjects.isNotEmpty) {
_snapState = snapState.copyWith(infoMessage: kRefreshMessage);
await WidgetsBinding.instance.endOfFrame;
if (_isInheritedDirty) {
_isInheritedDirty = false;
} else {
for (final inj in inheritedInjects) {
inj.refresh(infoMessage: kRecomputing);
}
}
if (inheritedInjects.isNotEmpty) {
notify(
nextSnap: inheritedInjects.last.snapValue,
);
}
try {
return await stateAsync;
} catch (e) {
return _snapState.data;
}
}
return super.refresh();
}