Does anyone know how to show a loading dialog or screen using Go router
i have to call an api service in order to get the route path so i ahve to show a progress bar in a dialog how can. i achieve that using go router
Does anyone know how to show a loading dialog or screen using Go router
i have to call an api service in order to get the route path so i ahve to show a progress bar in a dialog how can. i achieve that using go router
2
Answers
You could use the root of the router as Loading-Page where you can fetch data from an API and display a Progress-Indicator in the meantime. When finished, you can navigate to your main-page.
Asynchronous functions, like calling a URL in the web, an online image reference, or calling an API, allow you to set specific functions that track the Request status and Response.
Here’s a simple example on how to call a URL with Dart (Flutter):
if you use a Future, you can set a FutureBuilder, which changes accordingly if you have or have not the expected response.
Another way to set a Future callback is to literally call it like this:
The cons of this last method, are that you need to do a manual validation of the response, check if there was an error in the call, and if the service response is valid or not.