mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-27 11:16:45 +00:00
fix(router): PopUpDialogs couldn't find the context.
This commit is contained in:
parent
ee9b8a4e31
commit
3366585d76
|
@ -7,10 +7,14 @@ class NavigationService {
|
|||
GlobalKey<ScaffoldMessengerState>();
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
NavigatorState? get navigator => navigatorKey.currentState;
|
||||
|
||||
void showPopUpDialog(final AlertDialog dialog) {
|
||||
final BuildContext context = navigatorKey.currentState!.overlay!.context;
|
||||
final BuildContext? context = navigatorKey.currentContext;
|
||||
|
||||
if (context == null) {
|
||||
showSnackBar(
|
||||
'Could not show dialog. This should not happen, please report this.');
|
||||
return;
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
|
|
|
@ -63,12 +63,10 @@ class SelfprivacyApp extends StatelessWidget {
|
|||
final ThemeData lightThemeData;
|
||||
final ThemeData darkThemeData;
|
||||
|
||||
final _appRouter = RootRouter();
|
||||
final _appRouter = RootRouter(getIt.get<NavigationService>().navigatorKey);
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => Localization(
|
||||
child: AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: SystemUiOverlayStyle.light, // Manually changing appbar color
|
||||
child: BlocAndProviderConfig(
|
||||
child: BlocBuilder<AppSettingsCubit, AppSettingsState>(
|
||||
builder: (
|
||||
|
@ -104,6 +102,5 @@ class SelfprivacyApp extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -231,9 +231,7 @@ class _SshKeysCard extends StatelessWidget {
|
|||
publicKey: key,
|
||||
),
|
||||
);
|
||||
Navigator.of(context)
|
||||
..pop()
|
||||
..pop();
|
||||
context.popRoute();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -99,7 +99,7 @@ Widget fadeThroughTransition(
|
|||
],
|
||||
)
|
||||
class RootRouter extends _$RootRouter {
|
||||
RootRouter();
|
||||
RootRouter(GlobalKey<NavigatorState> super.navigatorKey);
|
||||
}
|
||||
|
||||
// Function to map route names to route titles
|
||||
|
|
Loading…
Reference in a new issue