i want to display a global overlay loading instance in my main app widget it works fine inside materialApp but when i used go router and turn it into MaterialApp.router the state is changed but the ovelay did not show up
here is my old code (this works)
Widget build(BuildContext context) {
return MaterialApp(
title: 'My app',
theme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
indicatorColor: Colors.blueGrey,
),
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark,
debugShowCheckedModeBanner: false,
home: Consumer(
builder: (context, ref, child) {
ref.listen<bool>(isLoadingProvider, (_, isloading) {
if (isloading) {
LoadingScreen.instance().show(context: context);
} else {
LoadingScreen.instance().hide();
}
});
final isLoggedId = ref.watch(isLoggedInProvider);
if (isLoggedId) {
return const MainView();
} else {
return const AuthPage();
}
},
),
);
}
new code with go router (this does not work)
ref.listen<bool>(isLoadingProvider, (_, isloading) {
if (isloading) {
LoadingScreen.instance().show(context: context);
} else {
LoadingScreen.instance().hide();
}
});
final router = ref.watch(routerProvider);
return MaterialApp.router(
title: 'my app',
theme: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.blue,
indicatorColor: Colors.blueGrey,
),
darkTheme: ThemeData.dark(),
themeMode: ThemeMode.dark,
debugShowCheckedModeBanner: false,
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
);