首页 > 解决方案 > MissingPluginException(未找到通道唤醒锁上的方法切换的实现) - 颤振唤醒锁

问题描述

当我使用唤醒锁时,我在调试控制台中收到此错误:

E/flutter (17630): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method toggle on channel wakelock)

这是我的代码:

import 'package:wakelock/wakelock.dart';

class _MyHomePageState extends State<MyHomePage> {
bool on = true;
// The following statement enables the wakelock.
 void initState() {
    super.initState();
    Wakelock.toggle(on: on);
}

我也确实在我的 AndroidManifest.xml 中添加了这个 <uses-permission android:name="android.permission.WAKE_LOCK" />

这在依赖项中:wakelock: ^0.1.4+2

我该如何解决这个问题?

标签: flutterdartmobile

解决方案


停止调试器,在终端中执行“flutter clean”并重新启动应用程序。


推荐阅读