The method 'registerMessageHandler' isn't defined for the type 'Registrar'

Viewed 2801
import 'package:cloud_firestore_web/cloud_firestore_web.dart';
import 'package:firebase_analytics_web/firebase_analytics_web.dart';
import 'package:firebase_auth_web/firebase_auth_web.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:fluttertoast/fluttertoast_web.dart';
import 'package:google_sign_in_web/google_sign_in_web.dart';
import 'package:pak_farmer/models/Register.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';

// ignore: public_member_api_docs

void registerPlugins(Registrar registrar) {

  FirebaseFirestoreWeb.registerWith (registrar);
  FirebaseAnalyticsWeb.registerWith(registrar);
  FirebaseAuthWeb.registerWith(registrar);
  FirebaseCoreWeb.registerWith(registrar);
  FluttertoastWebPlugin.registerWith(registrar);
  GoogleSignInPlugin.registerWith(registrar);
  SharedPreferencesPlugin.registerWith(registrar);
  registrar**.registerMessageHandler();**
  
}

I've written this code but it is giving me an error on the last line:

The method 'registerMessageHandler' isn't defined for the type 'Registrar'.

4 Answers

my error gone with flutter clean once and it will work fine for me

flutter clean didn't work for me. My problem was that I made the project in the Flutter beta channel and then opened in the stable channel. When I switched back to beta it was OK. Once web support enters stable this shouldn't be a problem anymore.

I faced the same issue when I downgraded Flutter from 2.0.0+ to 1.22.6. Developed the web panel in 2.0.0+ but after downgrading it for another app, saw this.

The error is likely if you created the project in stable version and for some reason you downgraded to a lower Flutter version.

FIX: Upgrade to the higher / updated version OR check the channel it was built on and shift to that channel.

You can see which channel you are currently on with flutter channel in your cmd.

Delete that autoGenerated file and run the application.

Related