Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'.

like image 675
Abd ur Rehman Avatar asked Feb 04 '21 07:02

Abd ur Rehman


People also ask

Is it possible to register a message handler in flutter?

The method 'registerMessageHandler' isn't defined for the type 'Registrar'. Show activity on this post. Show activity on this post. 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.

Is the method(methodname) undefined for the type(ClassName)?

The method (methodName) undefined for the type (className) Specific errors The method contains(String) is undefined for the type String The method codePointAt(String) is undefined for the type String

What is the difference between the method format(string) and gettypeparameters(typevariable)?

The method format(String) is undefined for the type String The method getTypeParameters(typeVariable) is undefined for the type typeVariable

What does this error message appear in Java when method not defined?

This error message appears in java when the method is not defined in that class. If you getting these errors for methods related to String or Collection Classes most likely the problem is because of JDK compliance level or installed JRE. All these methods compiles with JDK 1.5 or above.


Video Answer


3 Answers

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

like image 159
raja usama Avatar answered Oct 18 '22 20:10

raja usama


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.

like image 35
Suragch Avatar answered Oct 18 '22 21:10

Suragch


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.

like image 1
icyNerd Avatar answered Oct 18 '22 20:10

icyNerd