Для initState:
Код: Выделить всё
initState() {
super.initState();
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
var initializationSettingsAndroid =
new AndroidInitializationSettings('app_icon');
var initializationSettingsIOS = new IOSInitializationSettings();
var initializationSettings = new InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
FlutterLocalNotificationsPlugin().initialize(initializationSettings, onSelectNotification: onSelectNotification);
}
Код: Выделить всё
showNotification() async {
var android = new AndroidNotificationDetails('Channel ID', 'Channel Name', 'channelDescription');
var iOS = new IOSNotificationDetails();
var platform = new NotificationDetails(android, iOS);
await flutterLocalNotificationsPlugin.show(
0, 'New Notification', 'Flutter Local Notif', platform,payload: 'test notification');
}
Ошибка: «PlatformException (PlatformException (ошибка, попытка вызвать виртуальный метод 'int java.lang.Integer.intValue()' в нулевая ссылка на объект, null))"
Я уже пробовал использовать документацию и YouTube, но всегда получаю эту ошибку сообщение
Подробнее здесь: https://stackoverflow.com/questions/568 ... tification
Мобильная версия