rrousselGit / provider

InheritedWidgets, but simple
https://pub.dev/packages/provider
MIT License
5.09k stars 508 forks source link

Throw ProviderNotFoundException #782

Closed vvvirani closed 1 year ago

vvvirani commented 1 year ago

I have already registered providers under MultiProviders class. Every provider class extends with ChangeNotifier class. But it throws ProviderNotFoundException exception.

I have used the latest package version: 6.0.3

I have attached a screenshot.

Screenshot 2022-10-05 at 12 07 20 PM
rrousselGit commented 1 year ago

I'll need a complete example. I can't help otherwise

vvvirani commented 1 year ago

This problem facing after updating flutter SDK 2.10.5 to 3.3.3.

I will share screenshot step by step.

vvvirani commented 1 year ago

Step 1: Create CartTest class with ChangeNotifier

Screenshot 2022-10-05 at 12 38 02 PM

Step 2: Register CartTest call under MultiProvider class

Screenshot 2022-10-05 at 12 39 06 PM

Step 3: Read CartTest class home screen

Screenshot 2022-10-05 at 12 40 33 PM

Throw error ProviderNotFoundException Could not find the current Provider

rrousselGit commented 1 year ago

That's not really what I asked for. I'd need a complete example, something I can execute (that's not your entire app). You're cutting too much with your screenshot. So I can't know what happens.

But for starter it'd help if you could share the stacktrace and the code that the stacktrace points to.

nervouna commented 1 year ago

I'd need a complete example, something I can execute (that's not your entire app).

@vvvirani To provide such example:

flutter create bug
cd bug
flutter pub add provider
flutter pub get

Write the minimal code needed to reproduce the bug in bug/lib/main.dart, run it in the simulator to make sure the bug reproduces, then copy & paste your code here in the comments.

@rrousselGit perhaps detailed instructions should be included in the issue template? Since this package is recommended in flutter starter guides, starters (like me) will certainly come every now and then.

vvvirani commented 1 year ago

I have already solved this problem. Thank you.