Skip to content
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

getProfile should run just after the Login Successful #89

Closed
Hard-Coder05 opened this issue Feb 11, 2021 · 3 comments · Fixed by #115
Closed

getProfile should run just after the Login Successful #89

Hard-Coder05 opened this issue Feb 11, 2021 · 3 comments · Fixed by #115
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Hard-Coder05
Copy link
Member

Hard-Coder05 commented Feb 11, 2021

Describe the bug

I require name and email for the sendFeedback function. So it is necessary that just after the user logs in the the profile data should get saved in the sharedPreferences.

Basically we need to shift the getProfile function to menu.dart and save the response recieved in shared Preferences.

@werainkhatri sir! What say on this?

@werainkhatri
Copy link
Member

Its better to move it to splash screen. In there, if the user is logged in, we can call the get_user_details api then and there. We can use provider to convey the User model object. But then cubit for profile will be useless.
Think what you can do and lemme know.

@Hard-Coder05
Copy link
Member Author

I guess as the user logs in we should call the getUserProfile that's a better approach according to me? What say?

@Hard-Coder05 Hard-Coder05 added bug Something isn't working help wanted Extra attention is needed labels Feb 16, 2021
@werainkhatri
Copy link
Member

I guess as the user logs in we should call the getUserProfile that's a better approach according to me? What say?

That should be the case when he's not logged in already. See, do this

in splash screen:
    If user is logged in
        get_user_details
        redirect to homescreen
    else
        redirect to loginscreen:
            when user logs in:
                get_user_details
                redirect to homescreen

ToDo:

  1. Remove ProfileCubit
  2. In SplashScreen, handle the api call directly and in LoginScreen, add it to the cubit
  3. add a Provider with User model just before the HomeScreen (whenever you redirect to homescreen, as you did for cubits)
  4. Get the User model using Provider.of<User>(context, listener: false) in the ProfileScreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants