Good day. I know that we use the onSelectNotification property to get the callback when the user tap on the notification in using the flutter local push notification package.
Future<void> _initialize() async {
await _configureLocalTimeZone();
AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
IOSInitializationSettings initializationSettingsIOS =
IOSInitializationSettings(
onDidReceiveLocalNotification: _onDidReceiveLocalNotification);
InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
await _flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: _onSelectNotification); // This is for the callback
}
This is the _onSelectsNotification function.
Future _onSelectNotification(String payload) async {
if (payload != null) {
print('notification payload: $payload');
}
BuildContext context;
await Navigator.of(context)
.push(MaterialPageRoute(builder: (BuildContext context) {
return NotificationsView();
})); // ***** This is not working. with no error.
}
I am not sure what to use for the context. I think the next route to the NotificationView() is not working because of the context value. Could you please help me with this issue? I am now using the GetX for the state management.
Thanks.