some changes towards loading the notification page when tapping a notification and when it triggers

This commit is contained in:
broodjeaap89 2021-08-16 21:48:31 +02:00
parent 94807016d8
commit b4567cc7b2

View file

@ -64,10 +64,17 @@ void main() async {
final String? timeZoneName = await FlutterNativeTimezone.getLocalTimezone(); final String? timeZoneName = await FlutterNativeTimezone.getLocalTimezone();
tz.setLocalLocation(tz.getLocation(timeZoneName!)); tz.setLocalLocation(tz.getLocation(timeZoneName!));
final NotificationAppLaunchDetails? notificationAppLaunchDetails = await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails();
String initialRoute = "/";
if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) {
selectedNotificationPayload = notificationAppLaunchDetails!.payload;
initialRoute = "/event/notification";
}
runApp( runApp(
MaterialApp( MaterialApp(
title: "PizzaPlanner", title: "PizzaPlanner",
home: PizzaPlanner(), initialRoute: initialRoute,
onGenerateRoute: RouteGenerator.generateRoute, onGenerateRoute: RouteGenerator.generateRoute,
) )
); );
@ -116,7 +123,11 @@ class RouteGenerator {
return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent)); return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent));
} }
case "/event/notification": { case "/event/notification": {
return MaterialPageRoute(builder: (context) => PizzaEventNotificationPage(settings.arguments as String?)); var argument = settings.arguments as String;
if (selectedNotificationPayload != null) {
argument = selectedNotificationPayload!;
}
return MaterialPageRoute(builder: (context) => PizzaEventNotificationPage(argument));
} }
default: { default: {