Error while trying to integrate firebased cloud notification into Dart

Asked

Viewed 71 times

0

Guys, I’m trying to push Notifications to my application users in Flutter, however when I do the method

void initState() {
\\\\\
}

and configure the entire notification system, the compiler returns me an error of: This method overrides a method annotated as @mustCallSuper in 'State', but does not invoke the overridden method.

I’m not understanding the cause of the error, the notification configuration process is correct, follow the complete code here:

class _MyHomePageState extends State<MyHomePage> {    
String textValue = 'Hello World';
  FirebaseMessaging firebaseMessaging = new FirebaseMessaging();
  @override  
  void initState() {
    firebaseMessaging.configure(
      onLaunch: (Map<String, dynamic> msg){
        print(" onLaunch called");
      },
      onResume: (Map<String, dynamic> msg){
        print(" onResume called");
      },
      onMessage: (Map<String, dynamic> msg){
        print(" onMessage called");
      }
    );
    firebaseMessaging.requestNotificationPermissions(
      const IosNotificationSettings(
        sound: true,
        alert: true,
        badge: true
      )
    );
    firebaseMessaging.onIosSettingsRegistered.listen((IosNotificationSettings setting){
    print('IOS Setting Registed');
    });
    firebaseMessaging.getToken().then((token){
      update(token);
    });
  }
  update(String token){
    print(token);
    textValue = token;
    setState((){

    });
  }

}

1 answer

0

The old update did not require the command super.initState(); after the

void initState(){

}

However, the block command is currently required, in case someone has the same problem as mine, possibly this is the solution, anything try to give a flutter upgrade in the tbm console.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.