navihate to notificatons when after click on push notification
This commit is contained in:
@@ -50,11 +50,14 @@ class LoginScreenRoute extends GoRouteData with _$LoginScreenRoute {
|
||||
// splash route - outside the shell
|
||||
@TypedGoRoute<SplashScreenRoute>(path: '/splash')
|
||||
class SplashScreenRoute extends GoRouteData with _$SplashScreenRoute {
|
||||
const SplashScreenRoute();
|
||||
final bool? navigateToNotification;
|
||||
const SplashScreenRoute({this.navigateToNotification});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, GoRouterState state) {
|
||||
return const SplashScreen();
|
||||
return SplashScreen(
|
||||
navigateToNotification: navigateToNotification ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,24 @@ RouteBase get $splashScreenRoute => GoRouteData.$route(
|
||||
);
|
||||
|
||||
mixin _$SplashScreenRoute on GoRouteData {
|
||||
static SplashScreenRoute _fromState(GoRouterState state) =>
|
||||
const SplashScreenRoute();
|
||||
static SplashScreenRoute _fromState(GoRouterState state) => SplashScreenRoute(
|
||||
navigateToNotification: _$convertMapValue(
|
||||
'navigate-to-notification',
|
||||
state.uri.queryParameters,
|
||||
_$boolConverter,
|
||||
),
|
||||
);
|
||||
|
||||
SplashScreenRoute get _self => this as SplashScreenRoute;
|
||||
|
||||
@override
|
||||
String get location => GoRouteData.$location('/splash');
|
||||
String get location => GoRouteData.$location(
|
||||
'/splash',
|
||||
queryParams: {
|
||||
if (_self.navigateToNotification != null)
|
||||
'navigate-to-notification': _self.navigateToNotification!.toString(),
|
||||
},
|
||||
);
|
||||
|
||||
@override
|
||||
void go(BuildContext context) => context.go(location);
|
||||
@@ -71,6 +84,26 @@ mixin _$SplashScreenRoute on GoRouteData {
|
||||
void replace(BuildContext context) => context.replace(location);
|
||||
}
|
||||
|
||||
T? _$convertMapValue<T>(
|
||||
String key,
|
||||
Map<String, String> map,
|
||||
T? Function(String) converter,
|
||||
) {
|
||||
final value = map[key];
|
||||
return value == null ? null : converter(value);
|
||||
}
|
||||
|
||||
bool _$boolConverter(String value) {
|
||||
switch (value) {
|
||||
case 'true':
|
||||
return true;
|
||||
case 'false':
|
||||
return false;
|
||||
default:
|
||||
throw UnsupportedError('Cannot convert "$value" into a bool.');
|
||||
}
|
||||
}
|
||||
|
||||
RouteBase get $appShellRouteData => StatefulShellRouteData.$route(
|
||||
parentNavigatorKey: AppShellRouteData.$parentNavigatorKey,
|
||||
factory: $AppShellRouteDataExtension._fromState,
|
||||
|
||||
Reference in New Issue
Block a user