persistedCreator method

FutureOr<T?> persistedCreator()

Implementation

FutureOr<T?> persistedCreator() {
  if (persistanceProvider == null) {
    return null;
  }
  persistanceProvider!.cachedJson = null;
  storageProviders.add(persistanceProvider!);

  late FutureOr<T?> Function() c;

  // if (this is InjectedAuth) {
  //   _coreRM.persistanceProvider!.persistOn = PersistOn.manualPersist;
  // }
  var result = persistanceProvider!.read();
  if (result is Future) {
    c = () async {
      dynamic innerResult = await (result as Future);
      result = null;
      if (innerResult is Function) {
        innerResult = await innerResult();
        if (innerResult is Function) {
          innerResult = await innerResult();
        }
      }
      return innerResult as T?;
    };
  } else {
    c = () {
      final r = result as T?;
      result = null;

      return r;
    };
  }
  return c();
}