【问题标题】:Displaying widget in notification in flutter在颤动的通知中显示小部件
【发布时间】:2021-07-09 05:57:06
【问题描述】:

我想使用颤振在通知中显示一个小部件。我正在使用 awesome_notifications 包,但我无法达到同样的效果。

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
      ),
    );

  }

在这个sn-p中有bigPicture参数,需要图片的url。我已使用 repaintBoundary 将小部件转换为图像。有什么方法可以传递图像小部件而不是 url?谢谢。

【问题讨论】:

    标签: android flutter notifications flutter-notification


    【解决方案1】:

    您可以使用 Uri.file 构造函数。这是一个使用相机文件的示例。

      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),
    );
    

    }

    【讨论】:

      猜你喜欢
      • 2021-10-22
      • 2021-10-19
      • 2022-11-13
      • 2022-12-25
      • 2019-10-27
      • 2019-03-19
      • 2021-01-22
      • 2021-07-13
      • 2022-06-28
      相关资源
      最近更新 更多