GithubHelp home page GithubHelp logo

Comments (6)

rrousselGit avatar rrousselGit commented on May 30, 2024 1

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.

rrousselGit avatar rrousselGit commented on May 30, 2024

Duplicate of #1874

from riverpod.

eli1stark avatar eli1stark commented on May 30, 2024

@rrousselGit

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.

rrousselGit avatar rrousselGit commented on May 30, 2024

Your notipod did not specify dependencies on podB

from riverpod.

eli1stark avatar eli1stark commented on May 30, 2024

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.

eli1stark avatar eli1stark commented on May 30, 2024

Thank you, Remi, now it's clear.

from riverpod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.