Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProviderContainer.exists doesn't ask parent #2177

Closed
nikitadol opened this issue Feb 13, 2023 · 1 comment · Fixed by #3158
Closed

ProviderContainer.exists doesn't ask parent #2177

nikitadol opened this issue Feb 13, 2023 · 1 comment · Fixed by #3158
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nikitadol
Copy link

Describe the bug
ProviderContainer.exists doesn't ask parent

To Reproduce

import 'package:riverpod/riverpod.dart';

final testProvider = Provider((ref) => 1);

void main() {
  final rootContainer = ProviderContainer();

  print(rootContainer.exists(testProvider)); // false
  print(rootContainer.read(testProvider)); // 1
  print(rootContainer.exists(testProvider)); // true

  final childContainer = ProviderContainer(
    parent: rootContainer,
  );

  print(childContainer.exists(testProvider)); // false
  print(childContainer.read(testProvider)); // true
  print(childContainer.exists(testProvider)); // false
}

Expected behavior
Must ask parent

@nikitadol nikitadol added bug Something isn't working needs triage labels Feb 13, 2023
@rrousselGit
Copy link
Owner

Added scenario: This should handle provider overrides. If a provider is overridden by a container, then the container should no-longer ask the parent

@rrousselGit rrousselGit self-assigned this May 10, 2023
@rrousselGit rrousselGit added this to the Riverpod 3.0 milestone Oct 15, 2023
rrousselGit added a commit that referenced this issue Nov 26, 2023
Fix ref.exists not checking ancestor containers.

fixes #2177
fixes #2044
rrousselGit added a commit that referenced this issue Nov 26, 2023
Fix ref.exists not checking ancestor containers.

fixes #2177
fixes #2044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants