0

The pub.dev Firebase Messaging example located at the link below fails to compile in the Flutter/Android Studio with the following error:

Undefined class 'MessageArguments'.

screen

The source code and libraries are here: [https://github.com/firebase/flutterfire/tree/master/packages/firebase_messaging/firebase_messaging/example][2]

Has anyone successfully compiled this example, and/or do you have suggestions how to resolve this error?

1
  • Did you import the required library? Commented Aug 4, 2022 at 12:34

1 Answer 1

1

You can use this and it is from message.dart

/// Message route arguments.
class MessageArguments {
  /// The RemoteMessage
  final RemoteMessage message;

  /// Whether this message caused the application to open.
  final bool openedApplication;

  // ignore: public_member_api_docs
  MessageArguments(this.message, this.openedApplication);
}

Also It is better to accept null from route.

final MessageArguments? args = ModalRoute.of(context)?.settings.arguments; 

Do a null check when using this args.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice tip, Yeasin. I'm wondering why my copy of message.dart does not have this class definition? Inserting your code into the copy of message.dart that I downloaded from the example resolves the error, but new ones pop up regarding message_list. In any case, how does one download the entire project from Git? I see no button that says 'download' or 'clone' so I have been manually copying and pasting the code. Thoughts?
I think example doesn't comes with installing package. You generally dont have to download/clone unless you like to make changes on package. just include on pinspec.yaml and it will good to go

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.