restoreCachedStateSync method

  1. @protected
void restoreCachedStateSync()

Tries to restore cached state

If cached state is empty does nothing if cached state is not empty calls onRestore

Implementation

@protected
void restoreCachedStateSync() {
  if (!stateFulInstanceSettings.isRestores) {
    return;
  }

  final stateFromCacheJsonString = UMvvmApp.cacheGetDelegate(
    stateFulInstanceSettings.stateId,
  );

  if (stateFromCacheJsonString == null || stateFromCacheJsonString.isEmpty) {
    return;
  }

  final restoredMap = json.decode(stateFromCacheJsonString);
  onRestore(restoredMap);
}