1

I want to display a widget in notification using flutter. I am using the awesome_notifications package but I am not able to achieve the same.

Future<void> triggerNotification() async{

    await AwesomeNotifications().createNotification(
      content: NotificationContent(
          id: 1,
          channelKey: 'key1',
          title: 'This is Notification title',
          body: 'This is Body of Noti',
          bigPicture: 'https://protocoderspoint.com/wp-content/uploads/2021/05/Monitize-flutter-app-with-google-admob-min-741x486.png',
          notificationLayout: NotificationLayout.BigPicture
      ),
    );

  }

In this snippet there is the bigPicture parameter that requires the url of the image. I have converted the widget to an image using repaintBoundary. Is there any way I can pass the image widget instead of the url? Thank You.

1 Answers1

0

You can use Uri.file constructor. Here's an example using a file from camera.

  Future<void> triggerNotification() async {
final PickedFile pickedFile = await _picker.getImage(source: ImageSource.camera);
Uri uri = Uri.file(pickedFile.path);
await AwesomeNotifications().createNotification(
  content: NotificationContent(
      id: 1,
      channelKey: 'basic_channel',
      title: 'This is Notification title',
      body: 'This is Body of Noti',
      bigPicture:
          uri.toString(),
      notificationLayout: NotificationLayout.BigPicture),
);

}