小编Dja*_*ada的帖子

类型不匹配:推断的类型是 PluginRegistry?但 FlutterEngine 是预料之中的

我想使用 Flutter Workmanager,我在我的 .kt 中做了这样的引用配置:

package com.example.mybackprocess

import be.tramckrijte.workmanager.WorkmanagerPlugin
import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.GeneratedPluginRegistrant

class App : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        WorkmanagerPlugin.setPluginRegistrantCallback(this)
    }

    override fun registerWith(reg: PluginRegistry?) {
        GeneratedPluginRegistrant.registerWith(reg)
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经改变android:name

android:name=".App"
Run Code Online (Sandbox Code Playgroud)

但它给了我这个错误:

在调试模式下在 G3212 上启动 lib\main.dart... e:E:\mybackprocess\android\app\src\main\kotlin\com\example\mybackprocess\MainActivity.kt: (15, 48): 类型不匹配:推断类型是 PluginRegistry?但 FlutterEngine 是预料之中的

FAILURE:构建失败,出现异常。* 出了什么问题:任务 ':app:compileDebugKotlin' 执行失败。编译错误。查看日志了解更多详情

尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。* 在https://help.gradle.org获得更多帮助

BUILD FAILED in 55s Gradle task assembleDebug failed with exit code 1 …

workmanagers flutter

6
推荐指数
1
解决办法
6667
查看次数

单击通知时路由到特定的颤动屏幕

如何在点击通知时转到特定屏幕?我在javascript中使用了云功能,当我点击通知时,它打开了我的应用程序而不是特定的屏幕

 _fcm.configure(
  onMessage: (Map<String, dynamic> message) async {
    print("onMessage: $message");
    getOrder(message['data']['order_id']);
    showDialog(
      context: context,
      builder: (context) => AlertDialog(
        content: ListTile(
          title: Text(message['notification']['title']),
          subtitle: Text(message['notification']['body']),
        ),
        actions: <Widget>[
          FlatButton(
            child: Text('Ok'),
            onPressed: () => Navigator.of(context).pop(),
          ),
        ],
      ),
    );
  },
  onLaunch: (Map<String, dynamic> message) async {
    print("onLaunch: $message");
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => DetailOrder()));
  },
  onResume: (Map<String, dynamic> message) async {
    print("onResume: $message");
    Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => DetailOrder()));
  },
);
Run Code Online (Sandbox Code Playgroud)

push-notification flutter google-cloud-functions firebase-cloud-messaging

1
推荐指数
1
解决办法
2749
查看次数