ECellNitrr / ECellApp2021

3 stars 3 forks source link

getProfile should run just after the Login Successful #89

Closed Hard-Coder05 closed 3 years ago

Hard-Coder05 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

werainkhatri commented 3 years ago

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