我在flutter中使用flutter_local_notifications插件,在初始化它时出现了这个错误。
The argument type 'Future<Null> Function(int, String, String, String)' can't be assigned to the parameter type 'Future<dynamic> Function(int, String?, String?, String?)?'
我正在使用的代码是:
void main() async {
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
WidgetsFlutterBinding.ensureInitialized();
WidgetsFlutterBinding.ensureInitialized();
var initializationSettingsAndroid = AndroidInitializationSettings('logo');
var initializationSettingsIOS = IOSInitializationSettings(
requestAlertPermission: true,
requestBadgePermission: true,
requestSoundPermission: true,
onDidReceiveLocalNotification:
(int id, String title, String body, String payload) async {}),//Error on this line
var initializationSettings = InitializationSettings(
android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: (String payload) async {
if (payload != null) {
debugPrint('notification payload: ' + payload);
}
});
runApp(MyApp());
}
有没有办法在这个函数中将 Future 转换为 Future>?
帮助将不胜感激。谢谢!