Flutter : Hot reload / Hot restart showing white screen with debug banner?
Asked Answered
M

3

5

In my flutter app , when I try to hot reload or hot restart , after process complete , the reloaded screen shows for a second and then went whole white

only the Debug banner in top right side showing

There is no errors in the console. It just says restarted application...

I need to stop and rerun the application !!!

Why ?

I am using auto route and river pod, fast_i18n for localization

I can't even figure out where is the problem and how explain ?

Sharing some code in gist

https://gist.github.com/RageshAntony/2288a47a8fdc24af1e570a0c7cb9ed08

Other project running without issues

Marrilee answered 20/1, 2022 at 17:43 Comment(0)
P
9

Make sure you don't initiate your router inside of the build function.

@override
Widget build(BuildContext context) {
  //remove this from here
  //you can just declare as a top level variable
  final AppRouter router= AppRouter();



  return MaterialApp.router(
    routeInformationParser: router.defaultRouteParser(),
    routerDelegate: router.delegate(),
    theme: ThemeData(
      primarySwatch: primaryColor,
    ),
  );
}
Paul answered 25/4, 2022 at 11:19 Comment(0)
B
2

Move your router from build method

Barkentine answered 18/4, 2022 at 9:40 Comment(0)
W
0

I found that this problem may be caused by the fact that the related code of auto route in the project is not configured correctly, because I also use it, and the same problem occurs. There is no solution to this problem yet, but an odd solution has been found that at least makes development slightly faster.

Open "Flutter DevTools", click "Select Widget Mode", the interface will appear.

hhhhhhhh...

Wildee answered 15/3, 2022 at 10:22 Comment(1)
Any solution found? Same problem here.Downstairs

© 2022 - 2024 — McMap. All rights reserved.