【发布时间】:2019-05-29 10:39:48
【问题描述】:
我想在指定的时间每天显示通知,并且我已经实现了显示每日通知的代码,但是在我想打电话的时候不显示通知是行不通的。我正在使用这个插件link
当我运行应用程序时,我在控制台上收到此警告,这是屏幕截图
我的代码实现有错吗? 这是代码
import 'package:flutter/material.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'dart:async';
class App extends StatefulWidget {
@override
_AppState createState() => _AppState();
}
class _AppState extends State<App> {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
showNotification() async{
var time = new Time(3,51, 0);//at 3.30
var androidPlatformChannelSpecifics =
new AndroidNotificationDetails('repeatDailyAtTime channel id',
'repeatDailyAtTime channel name', 'repeatDailyAtTime description');
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.showDailyAtTime(
0,
'Teer Result Time',
'Open The App and check for the Result',
time,
platformChannelSpecifics);
}
@override
void initState() {
// TODO: implement initState
super.initState();
showNotification();
}
@override
Widget build(BuildContext context) {
return Container(
);
}
}
【问题讨论】: