'Home Screen Loads Twice

I have a native Splash Screen so no need to create a new one here and need to set LoginPage as default as well I have authenticated status than define which route to follow

so I set onGenerateRoute: (_) =>LoginPage.route(), and it loads twice in release and profile mode

                case AuthenticationStatus.authenticated:
                  _navigator.pushAndRemoveUntil<void>(
                      HomePage.route(),
                          (route) => false
                  );
                  break;
                case AuthenticationStatus.unauthenticated:
                  _navigator.pushAndRemoveUntil<void>(
                      LoginPage.route(),
                          (route) => false
                  );
                  break;
                default:
                  break;
...
  onGenerateRoute: (_) =>LoginPage.route(),

How to save the same logic but without double loading?



Solution 1:[1]

I think the way your code is currently written is causing the double loading, your generateroute code should call a function and not a specific route. What I think is happening is that it checks unauthenticated, returns its route and then it checks the generate route, it re-returns the route again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Denzel