未处理的异常:MissingPluginException在频道 dexterous.com/flutter/local_notifications 上找不到方法显示的实现

问题描述

我面临 Flutter2 和本地通知插件的问题。当应用程序在前台时 - 本地通知工作正常,但当应用程序在后台时 - 我收到 MissingPluginException 错误

E/Flutter (18894): [ERROR:Flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method show on channel dexterous.com/Flutter/local_notifications)
E/Flutter (18894): #0      MethodChannel._invokeMethod (package:Flutter/src/services/platform_channel.dart:156:7)
E/Flutter (18894): <asynchronous suspension>
E/Flutter (18894): #1      FlutterlocalnotificationsPlugin.show (package:Flutter_local_notifications/src/Flutter_local_notifications_plugin.dart:179:7)
E/Flutter (18894): <asynchronous suspension>

我的发布规范:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  Flutter:
    sdk: Flutter

  Flutter_local_notifications: ^5.0.0+4

# firebase
  firebase_core: ^1.0.1
  firebase_auth: ^1.0.3
  cloud_firestore: ^1.0.4
  firebase_storage: ^8.0.3
  firebase_messaging: ^9.1.1
  firebase_core_platform_interface: ^4.0.0
  firebase_analytics: ^7.0.0
  firebase_dynamic_links: ^0.8.0
  firebase_crashlytics: ^2.0.3

还有我的 MainActivity 文件

import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.os.PersistableBundle
import com.dexterous.Flutterlocalnotifications.FlutterlocalnotificationsPlugin
import io.Flutter.embedding.android.FlutterActivity
import io.Flutter.embedding.engine.FlutterEngine
import io.Flutter.plugin.common.MethodCall
import io.Flutter.plugin.common.MethodChannel
import io.Flutter.plugin.common.PluginRegistry
import io.Flutter.plugins.FirebaseCloudMessagingPluginRegistrant
import io.Flutter.plugins.GeneratedpluginRegistrant
import io.Flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService
import zendesk.core.Zendesk


class MainActivity : FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?,persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState,persistentState)
    }


    override fun configureFlutterEngine(FlutterEngine: FlutterEngine) {
        super.configureFlutterEngine(FlutterEngine)
        MethodChannel(FlutterEngine.dartExecutor.binaryMessenger,channelName).setMethodCallHandler { call,result ->
            if (call.method == "start") {
                start(call,result)
            } else {
            }
        }
    }

}

我还发现应用启动时出现警告:

I/FLTFireBGExecutor(21072): Creating background FlutterEngine instance,with args: [--start-paused,--enable-dart-profiling]
W/FlutterEngine(21072): Tried to automatically register plugins with FlutterEngine (io.Flutter.embedding.engine.FlutterEngine@b3b4ecc) but Could not find and invoke the GeneratedpluginRegistrant.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)