参数类型' string'可以将参数类型分配给androidNotificationund'

发布于 2025-01-24 02:10:21 字数 928 浏览 0 评论 0原文

这是DART分析信息:

error: The argument type 'String' can't be assigned to the parameter type 'AndroidNotificationSound'. (argument_type_not_assignable at [mediminder] lib/src/ui/new_entry/new_entry.dart:335)

和文件“ new_entry.dart”仍然从这里出发:

Future _showNotificationWithSound() async {
  var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      'your channel id', 'your channel name',
      sound: 'sneezenotification',
      importance: Importance.max,
      priority: Priority.high);

  var platformChannelSpecifics = new NotificationDetails(
     android: androidPlatformChannelSpecifics);
  await flutterLocalNotificationsPlugin.show(
    0,
    'New Post',
    'How to Show Notification in Flutter',
    platformChannelSpecifics,
    payload: 'Custom_Sound',
  );
}

错误在线

声音中:'sneezenotification'。 注意:我已经添加了sneezn Notification.mp3在Android中

this is the dart analyses info:

error: The argument type 'String' can't be assigned to the parameter type 'AndroidNotificationSound'. (argument_type_not_assignable at [mediminder] lib/src/ui/new_entry/new_entry.dart:335)

and the file "new_entry.dart" still te same original one from here:

Future _showNotificationWithSound() async {
  var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
      'your channel id', 'your channel name',
      sound: 'sneezenotification',
      importance: Importance.max,
      priority: Priority.high);

  var platformChannelSpecifics = new NotificationDetails(
     android: androidPlatformChannelSpecifics);
  await flutterLocalNotificationsPlugin.show(
    0,
    'New Post',
    'How to Show Notification in Flutter',
    platformChannelSpecifics,
    payload: 'Custom_Sound',
  );
}

the error is in the line

sound: 'sneezenotification'.
Note: I already added sneeze notification.mp3 in android>app>res>raw

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昇り龍 2025-01-31 02:10:21
sound: RawResourceAndroidNotificationSound('sneezenotification'),

这样更改并更改“ channel_id 3”的工作

sound: RawResourceAndroidNotificationSound('sneezenotification'),

Change like this and change "channel_id 3" its work for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文