【发布时间】:2021-11-11 09:15:02
【问题描述】:
我正在尝试实现本地通知,但我遇到了 NoSuchMethodError,我已经调试了代码并找到了问题,但没有找到正确的解决方案。 我在 AddNotification.dart Stateful 类中创建了我这样称呼它的通知管理器类
final NotificationManager manager;
const AddNotification(this.manager);
然后在它的 State 类中这样调用它:
widget.manager.showNotificationDaily(1, "Asar", "isNotification", hour, minute);
在调用 AddNotification 的上一个类中,我发送了一个这样的通知管理器对象。
class AllSurah extends StatefulWidget {
NotificationManager manager;
@override
_AllSurahState createState() => _AllSurahState();
}
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddNotification(widget.manager)),
);
我已经调试了代码,发现管理器正在从传递 NotificationManger 对象的上一个类传递 null。我该如何解决这个问题?
【问题讨论】:
标签: flutter dart flutter-local-notification