DEV Community

Cover image for PluginRegistry cannot be converted to FlutterEngine In Flutter - fluttercorner.com
FlutterCorner
FlutterCorner

Posted on

PluginRegistry cannot be converted to FlutterEngine In Flutter - fluttercorner.com

Hello Guys How Are you all? hope you all are fine. today when I updated my flutter version, suddenly I got the following error: “error: incompatible types: PluginRegistry cannot be converted to FlutterEngine GeneratedPluginRegistrant.registerWith (registry); ” from firebase_messaging plugin.

I Got This Error From firebase_messaging plugin

error: incompatible types: PluginRegistry cannot be converted to FlutterEngine
    GeneratedPluginRegistrant.registerWith(registry);
Enter fullscreen mode Exit fullscreen mode

Line where I Got This Error

  public void registerWith(PluginRegistry registry) {
    GeneratedPluginRegistrant.registerWith(registry);
  }
Enter fullscreen mode Exit fullscreen mode

Solution

Replace this code line:

Here is all possible solutions added PluginRegistry cannot be converted to FlutterEngine In Flutter

Top comments (1)

Collapse
 
uv3301 profile image
Yuvraj Singh

This didn't work for me, but some research and I found this to be working:
on firabase_messaging: 9.0.0

//
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingBackgroundService;
import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin;

public class CustomFlutterApplication extends FlutterApplication implements PluginRegistrantCallback {
//
@Override
  public void onCreate() {
        super.onCreate();
        FlutterFirebaseMessagingBackgroundService.setPluginRegistrant(this);
    }
 @Override
  public void registerWith(PluginRegistry registry) {
 FlutterFirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
  }
}
Enter fullscreen mode Exit fullscreen mode