Comments (6)
For the same reason why podB
specifies dependencies: [podA]
When podA is scoped, we want also to scope all of its dependents (podB).
That logic is recursive. Now that podB is scoped, we want also to scope all of its dependents (notipod).
The whole tree of dependents and transitive dependents relying on a scoped provider need to specify dependencies
.
You should see an assert telling you you're missing a dependencies
. And riverpod_lint should show a warning + quick fix too (although only if you were using codegen)
from riverpod.
Duplicate of #1874
from riverpod.
I added the code to the main:
FlutterError.demangleStackTrace = (stack) {
if (stack is Trace) return stack.vmTrace;
if (stack is Chain) return stack.toTrace().vmTrace;
return stack;
};
But this issue was more about why notipod
is crashing.
I have this error now, which is more clear with demangleStackTrace
but still remains an error.
Error
#1527 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:535:23)
#1528 ConsumerStatefulElement.watch
consumer.dart:553
#1529 Home.build
main_development.dart:74
#1530 _ConsumerState.build
consumer.dart:479
#1531 StatefulElement.build
framework.dart:5198
#1532 ConsumerStatefulElement.build
consumer.dart:542
#1533 ComponentElement.performRebuild
framework.dart:5086
#1534 StatefulElement.performRebuild
framework.dart:5251
#1535 Element.rebuild
framework.dart:4805
#1536 ComponentElement._firstBuild
framework.dart:5068
#1537 StatefulElement._firstBuild
framework.dart:5242
#1538 ComponentElement.mount
framework.dart:5062
... Normal element mounting (24 frames)
#1562 Element.inflateWidget
framework.dart:3971
#1563 MultiChildRenderObjectElement.inflateWidget
framework.dart:6570
#1564 MultiChildRenderObjectElement.mount
framework.dart:6582
... Normal element mounting (178 frames)
#1742 Element.inflateWidget
framework.dart:3971
#1743 MultiChildRenderObjectElement.inflateWidget
framework.dart:6570
#1744 MultiChildRenderObjectElement.mount
framework.dart:6582
... Normal element mounting (94 frames)
#1838 _UncontrolledProviderScopeElement.mount
framework.dart:309
... Normal element mounting (399 frames)
#2237 _UncontrolledProviderScopeElement.mount
framework.dart:309
... Normal element mounting (35 frames)
#2272 Element.inflateWidget
framework.dart:3971
#2273 Element.updateChild
framework.dart:3708
#2274 RenderObjectToWidgetElement._rebuild
binding.dart:1240
#2275 RenderObjectToWidgetElement.mount
binding.dart:1209
#2276 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
binding.dart:1156
#2277 BuildOwner.buildScope
framework.dart:2720
#2278 RenderObjectToWidgetAdapter.attachToRenderTree
binding.dart:1155
#2279 WidgetsBinding.attachRootWidget
binding.dart:988
#2280 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure>
binding.dart:968
#2284 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
#2285 podA.<anonymous closure>
main_development.dart:26
#2286 ProviderElementBase.watch
element.dart:713
#2287 podB.<anonymous closure>
main_development.dart:32
#2288 ProviderElementBase.read
element.dart:690
#2289 MyNotifier.build
main_development.dart:42
#2290 ProviderContainer.listen
container.dart:285
#2291 ConsumerStatefulElement.watch.<anonymous closure>
consumer.dart:560
#2292 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:535:23)
#2293 ConsumerStatefulElement.watch
consumer.dart:553
#2294 Home.build
main_development.dart:74
#2295 _ConsumerState.build
consumer.dart:479
#2296 StatefulElement.build
framework.dart:5198
#2297 ConsumerStatefulElement.build
consumer.dart:542
#2298 ComponentElement.performRebuild
framework.dart:5086
#2299 StatefulElement.performRebuild
framework.dart:5251
#2300 Element.rebuild
framework.dart:4805
#2301 ComponentElement._firstBuild
framework.dart:5068
#2302 StatefulElement._firstBuild
framework.dart:5242
#2303 ComponentElement.mount
framework.dart:5062
... Normal element mounting (24 frames)
#2327 Element.inflateWidget
framework.dart:3971
#2328 MultiChildRenderObjectElement.inflateWidget
framework.dart:6570
#2329 MultiChildRenderObjectElement.mount
framework.dart:6582
... Normal element mounting (178 frames)
#2507 Element.inflateWidget
framework.dart:3971
#2508 MultiChildRenderObjectElement.inflateWidget
framework.dart:6570
#2509 MultiChildRenderObjectElement.mount
framework.dart:6582
... Normal element mounting (94 frames)
#2603 _UncontrolledProviderScopeElement.mount
framework.dart:309
... Normal element mounting (399 frames)
#3002 _UncontrolledProviderScopeElement.mount
framework.dart:309
... Normal element mounting (35 frames)
#3037 Element.inflateWidget
framework.dart:3971
#3038 Element.updateChild
framework.dart:3708
#3039 RenderObjectToWidgetElement._rebuild
binding.dart:1240
#3040 RenderObjectToWidgetElement.mount
binding.dart:1209
#3041 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
binding.dart:1156
#3042 BuildOwner.buildScope
framework.dart:2720
#3043 RenderObjectToWidgetAdapter.attachToRenderTree
binding.dart:1155
#3044 WidgetsBinding.attachRootWidget
binding.dart:988
#3045 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure>
binding.dart:968
#3049 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
(elided 12 frames from class _Timer and dart:async-patch)
════════════════════════════════════════════════════════════════════════════════
I think I can rephrase the issue now to: "Override with value doesn't work properly when accessed from Notifier".
Value of podA
in my example is defined for Widget.build
but for Notifier.build
is still undefined.
from riverpod.
Your notipod
did not specify dependencies
on podB
from riverpod.
Hmm, yes, that works, thank you.
But if I create
final podC = Provider<int>((ref) => 2);
And use it like so:
class MyNotifier extends Notifier<int> {
@override
int build() => ref.read(podC) + 1;
}
notipod
doesn't require any dependencies to work properly, why is so?
from riverpod.
Thank you, Remi, now it's clear.
from riverpod.
Related Issues (20)
- ImageProvider generated as InvalidType HOT 4
- `AutoDisposeProvider` is getting disposed when watched in a `StreamProvider` using `async*` HOT 1
- Provider container loses data in widget test HOT 4
- AutoDisposeNotifierProvider causing state loss HOT 3
- Reword `The ref.watch method should not be called asynchronously`
- Add a DevTools extension for riverpod HOT 2
- Broken update HOT 3
- [riverpod 3] NotifierProvider doesn't work with a NotifierBase mixin.
- riverpod_generator does not respect import aliases HOT 1
- Ref onError callback HOT 1
- `ref.exists()` returns `true` when manually invalidate a provider.
- `yarn dev -l {LANG}` is needed when hosting documentation website locally for specific locale with docusaurus
- Stream from StreamProvider is not unsubscribed to when widgets get disposed
- There is no way to handle the "done" event on the stream of a StreamProvider
- `ref.invalidate(familyProvider)` is not working with scoped providers
- PageController stateprovider doesn't work when .previousPage() or nextPage() is pressed
- beforeDispose or beforeInvalidate hook, happen before invalidate HOT 5
- Multiple invalidation of Providers HOT 1
- Unable to use the latest riverpod in flutter version lower than 3.16 HOT 2
- The getter 'variable2' isn't defined for the class 'PropertyAccessorElement'. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riverpod.