2
votes

The getter 'instance' isn't defined for the type 'FirebaseMessaging'. Try importing the library that defines 'instance', correcting the name to the name of an existing getter, or defining a getter or field named 'instance'.
I am trying to implement this sample code
https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart
But it is showing above mentioned error.
How to fix it?

firebase_messaging: ^7.0.3
import 'package:firebase_messaging/firebase_messaging.dart';

fcm flutter

1
Can you show us the code you've written? Specifically the imports and the error causing line ? - Midhun MP
@MidhunMP updated with question - Midhilaj
The instance property is available in the version 8 (which is in pre-release status). In 7 you have to use FirebaseMessaging() to create instance. - Midhun MP

1 Answers

1
votes

The getter 'instance' is not available on firebase_messaging: ^7.x.x , you will need to upgrade to version 8