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

Fix some typos + better error message for non-overridden dependencies #2452

Merged
merged 4 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/riverpod/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased fix

- Improved error message for missing `dependencies` (thanks to @ValentinVignal)
- Fixed various typos in the documentation (thanks to @ValentinVignal)

## 2.3.5 - 2023-04-18

- fix `AsyncValue.isReloading` docs
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod/lib/src/framework/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class ProviderContainer implements Node {
'''
Tried to read $provider from a place where one of its dependencies were overridden but the provider is not.

To fix this error, you can add "dependencies" to $provider such that we have:
To fix this error, you can add $dependency (a) to the "dependencies" of $provider (b) such that we have:

```
final a = Provider(...);
Expand Down
16 changes: 8 additions & 8 deletions packages/riverpod/lib/src/framework/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void Function()? debugCanModifyProviders;
///
/// This is what keeps track of the state of a provider, and notifies listeners
/// when the state changes. It is also responsible for rebuilding the provider
/// when once of its dependencies changes.
/// when one of its dependencies changes.
///
/// This class is not meant to be used directly and is an implemnetation detail
/// This class is not meant to be used directly and is an implementation detail
/// of providers.
/// Do not use.
/// {@endtemplate}
Expand Down Expand Up @@ -159,10 +159,10 @@ abstract class ProviderElementBase<State> implements Ref<State>, Node {
}
}

/// Obtains the current state, of null if the provider has yet to initialize.
/// Obtains the current state, or null if the provider has yet to initialize.
///
/// The returned object will contain error information, if any.
/// This function does not cause the provider to rebuild if it someohow was
/// This function does not cause the provider to rebuild if it somehow was
/// outdated.
///
/// This is not meant for public consumption. Instead, public API should use
Expand Down Expand Up @@ -453,7 +453,7 @@ abstract class ProviderElementBase<State> implements Ref<State>, Node {
void notifyListeners() {
final currentResult = getState();
// If `notifyListeners` is used during `build`, the result will be null.
// Throwing would be unnecesserily inconvenient, so we simply skip it.
// Throwing would be unnecessarily inconvenient, so we simply skip it.
if (currentResult == null) return;

if (_didBuild) {
Expand Down Expand Up @@ -623,7 +623,7 @@ The provider ${_debugCurrentlyBuildingElement!.origin} modified $origin while bu
if (listenable is! ProviderBase<Object?>) return true;

try {
// Initializating the provider, to make sure its dependencies are setup.
// Initializing the provider, to make sure its dependencies are setup.
_container.readProviderElement(listenable);
} catch (err) {
// We don't care whether the provider is in error or not. We're just
Expand All @@ -647,7 +647,7 @@ The provider ${_debugCurrentlyBuildingElement!.origin} modified $origin while bu
origin.dependencies!.contains(listenable.from) ||
origin.dependencies!.contains(listenable),
'The provider $origin tried to read $listenable, but it specified a '
"'dependendencies' list yet that list does not contain $listenable.\n\n"
"'dependencies' list yet that list does not contain $listenable.\n\n"
"To fix, add $listenable to $origin's 'dependencies' parameter",
);

Expand Down Expand Up @@ -793,7 +793,7 @@ The provider ${_debugCurrentlyBuildingElement!.origin} modified $origin while bu
void Function(Object error, StackTrace stackTrace)? onError,
}) {
// TODO do we want to expose a way to close the subscription?
// TODO do we want a fireImmdiately?
// TODO do we want a fireImmediately?

_onChangeSelfListeners ??= [];
_onChangeSelfListeners!.add(listener);
Expand Down