findIn method

T findIn(
  1. LevitScope scope, {
  2. String? tag,
})

Internal helper to resolve this state within a specific scope.

Implementation

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

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

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

  return instance.value;
}