Skip to content

Commit

Permalink
Fix some typos + better error message for non-overridden dependencies (
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinVignal committed Apr 19, 2023
1 parent 270ed48 commit f020046
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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

0 comments on commit f020046

Please sign in to comment.