Skip to content

Edit Profile and Owner's Info tab not working (Provider State Management) #79

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

Closed
Mohitmadhav opened this issue Oct 1, 2021 · 8 comments · Fixed by #146
Closed

Edit Profile and Owner's Info tab not working (Provider State Management) #79

Mohitmadhav opened this issue Oct 1, 2021 · 8 comments · Fixed by #146
Assignees
Labels
bug Something isn't working good first issue good issue for first-time contributors Hacktoberfest For Hacktoberfest 2021 high-priority Something that has a high priority medium medium level issue

Comments

@Mohitmadhav
Copy link
Member

Mohitmadhav commented Oct 1, 2021

Description

  • The Edit Profile Page isn't opening. The error is as shown below.
  • Same error occurs in the book description page when tapping on Owner's Info
  • Try it in your local system first

Screenshots

image
image

Steps to Reproduce

This has occurred because the provider hasn't been registered in main.dart.

  1. So either replace the Provider with Stream Provider (Initialized in home.dart)
  2. OR Extend the UserData function with ChangeNotifiers with relevant functions(If required)
  3. User Model : lib/providers/user.dart
  4. Book Description page: lib/screens/book_desciption.dart

Additional data

What better solution can be there to fix this issue? Go through the entire codebase for more clarity.

@Mohitmadhav Mohitmadhav added bug Something isn't working normal-priority Something that has a normal priority medium medium level issue labels Oct 1, 2021
@Mohitmadhav
Copy link
Member Author

The entire error is:

Exception has occurred.
ProviderNotFoundException (Error: Could not find the correct Provider above this EditProfile Widget

This happens because you used a BuildContext that does not include the provider
of your choice. There are a few common scenarios:

  • You added a new provider in your main.dart and performed a hot-reload.
    To fix, perform a hot-restart.

  • The provider you are trying to read is in a different route.

    Providers are "scoped". So if you insert of provider inside a route, then
    other routes will not be able to access that provider.

  • You used a BuildContext that is an ancestor of the provider you are trying to read.

    Make sure that EditProfile is under your MultiProvider/Provider.
    This usually happens when you are creating a provider and trying to read it immediately.

    For example, instead of:

    Widget build(BuildContext context) {
      return Provider<Example>(
        create: (_) => Example(),
        // Will throw a ProviderNotFoundError, because `context` is associated
        // to the widget that is the parent of `Provider<Example>`
        child: Text(context.watch<Example>()),
      ),
    }
    

    consider using builder like so:

    Widget build(BuildContext context) {
      return Provider<Example>(
        create: (_) => Example(),
        // we use `builder` to obtain a new `BuildContext` that has access to the provider
        builder: (context) {
          // No longer throws
          return Text(context.watch<Example>()),
        }
      ),
    }
    

If none of these solutions work, consider asking for help on StackOverflow:
https://stackoverflow.com/questions/tagged/flutter
)

@Mohitmadhav Mohitmadhav added the Hacktoberfest For Hacktoberfest 2021 label Oct 1, 2021
@Mohitmadhav Mohitmadhav changed the title Edit Profile not opening (Provider State Management) Edit Profile and Owner's Info tab not working (Provider State Management) Oct 2, 2021
@Mohitmadhav Mohitmadhav added high-priority Something that has a high priority good first issue good issue for first-time contributors and removed normal-priority Something that has a normal priority labels Oct 2, 2021
@boredcity
Copy link

I'll take a look at this one 🕵️

@Mohitmadhav
Copy link
Member Author

Mohitmadhav commented Oct 3, 2021

Cool @merelj, I'm assigning it to you.
Also, once go through the whole app and see if this behavior gets repeated, and try to solve that too because all of them have the same provider path issue.
And make sure to follow the README guidelines.

@Mohitmadhav
Copy link
Member Author

@merelj any updates?

@boredcity
Copy link

For now almost every page is either broken or empty whenever I start up the app: I cannot even navigate to book screen and Edit Profile Page does not have a working link to it 😕

Not sure if it has something to do with my setup, internet connection or problems with the code, but for now I don't think I have enough time on my hands to work through it without slowing you down, sorry 🙇

@Mohitmadhav
Copy link
Member Author

  • The Provider error is the same with these 2 pages (Profile and Owners info tab)
  • And Dashboard and Library page won't be empty if you add your book through the Add your book button on the Profile page
  • The rest empty pages have been allotted as issues to other people so don't worry about them

@merelj you try out to resolve them, and if not then you can unassign yourself and work on some other issue

@keyurgit45
Copy link
Contributor

can I work on this issue? @Mohitmadhav

@Mohitmadhav
Copy link
Member Author

Ok @keyurgit45.

Mohitmadhav added a commit that referenced this issue Oct 31, 2021
Fixes #79 
PR #146 
Edit Profile and Owner's Info tab fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue good issue for first-time contributors Hacktoberfest For Hacktoberfest 2021 high-priority Something that has a high priority medium medium level issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants