我正在学习 Flutter Hooks,但是当您需要具有通常在 initState 中的特定权限请求时,我找不到任何关于使用什么的信息,例如:
class _HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
_requestPermissions();
_configureDidReceiveLocalNotificationSubject();
_configureSelectNotificationSubject();
}
void _requestPermissions() {
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
MacOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
);
}...
现在迁移它以使用钩子 initState 和 dispose 不是“需要的”,因为它可以为您处理这在许多情况下都很好,但我无法理解在哪里放置这种类型的请求权限?
使用时如何请求这些权限class HomePage extends HookWidget
?