findAsyncIn method

Future<T> findAsyncIn(
  1. LevitScope scope, {
  2. String? tag,
})

Internal helper to resolve this state asynchronously within a specific scope.

Implementation

Future<T> findAsyncIn(LevitScope scope, {String? tag}) async {
  final instanceKey =
      tag != null ? 'ls_value_${getProviderTag(this, tag)}' : _defaultKey;

  var instance =
      await scope.findOrNullAsync<_LevitStateInstance<T>>(tag: instanceKey);

  if (instance == null) {
    scope.put(() => _LevitStateInstance<T>(this), tag: instanceKey);
    instance =
        await scope.findAsync<_LevitStateInstance<T>>(tag: instanceKey);
  }

  return instance.value;
}