0

I currently have implemented auto login, there is only a slight problem.

If a user logs in, I save their data in SharedPreferences.

Now, when the re opens the app it opens to the login screen makes an API call to check if the login is successful with the current SharedPreferences credentials.

Then if it returns 200 it pushes them to the home page of the application.

The problem is that there is a slight delay when the user opens the app because the user is authenticating with the backend. So we see the login page for 500ms and then it pushes to the home page.

How can I use a splash screen or something so we dont have this awkward 500ms delay.

1 Answers1

0

Use a FutureBuilder on your Login page. Show your splash screen while the future resolves, show the Login page if it did not succeed, navigate to the next page if it did.

Example for using a Future with a FutureBuilder:

What is a Future and how do I use it?

nvoigt
  • 75,013
  • 26
  • 93
  • 142