我正在为我的应用程序使用本地通知,我正在尝试设置onSelectNotification
但我无法使其工作。我就是这样init
:
Future initialize() async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
AndroidInitializationSettings androidInitializationSettings =
AndroidInitializationSettings('app_icon');
IOSInitializationSettings iosInitializationSettings =
IOSInitializationSettings();
final InitializationSettings initializationSettings =
InitializationSettings(
android: androidInitializationSettings,
iOS: iosInitializationSettings);
await flutterLocalNotificationsPlugin.initialize(
initializationSettings, onSelectNotification: onSelectNotification
);
}
我的onSelectNotification
:
Future onSelectNotification(String payload) async {
print(payload);
}
但是 Flutter 在抱怨:
参数类型“Future Function(String)”不能分配给参数类型“Future Function(String?)?”。
我在文档中找不到任何关于此的内容,在其他任何地方都找不到。我想念她什么?