I want to use the awesome_notifications package in my Flutter app to create a notification that can navigate to another page when the user taps on it. I'm able to create and display the notification, but I'm not sure how to handle the tap event and navigate to the desired page. How can I do this using awesome_notifications?
my Code:
import 'package:flutter/material.dart';
import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:workout_traker/main.dart';
class NotificationService {
Future<void> initNotification() async {
await AwesomeNotifications().initialize(
null,
[
NotificationChannel(
channelShowBadge: true,
channelKey: 'basic_channel',
enableVibration: true,
channelName: 'Basic notifications',
channelDescription: 'Notification channel for basic tests',
defaultColor: const Color(0xFF9D50DD),
ledColor: Colors.white,
importance: NotificationImportance.Max,
onlyAlertOnce: true,
playSound: true,
criticalAlerts: true,
),
],
);
}
Future<void> showNotification(
int id,
String title,
String body,
int hours,
int minutes,
String notificationImage,
BuildContext context,
) async {
await AwesomeNotifications().createNotification(
content: NotificationContent(
id: id,
channelKey: 'basic_channel',
title: title,
body: body,
bigPicture: 'asset://$notificationImage',
wakeUpScreen: true,
backgroundColor: Colors.deepOrange,
notificationLayout: NotificationLayout.BigPicture,
),
schedule: NotificationCalendar.fromDate(
date: DateTime.now().add(Duration(hours: hours, minutes: minutes)),
allowWhileIdle: true,
),
);
}
}
please help me guys!.
I already try asking chatGbt and all this what he give me , there is an error in
AwesomeNotifications().actionStream.listen((action){//...}