Home > Software engineering >  How can I convert this arrow function to a normal function?
How can I convert this arrow function to a normal function?

Time:09-08

I am working on a flutter application and I am trying to convert this arrow function to a normal one, but it is not working

_firebaseMessaging.getToken().then((value) => print('Token: $value'));

Can someone help me with it please ?

CodePudding user response:

Try this(what I recommend ):

var result = await _firebaseMessaging.getToken();
print('Token: $result');

or this:

_firebaseMessaging.getToken().then((value){
      print('Token: $value')
     });

CodePudding user response:

This might help you

_firebaseMessaging.getToken().then((value){

print('Token: $value');

}));

CodePudding user response:

(parameter) => expression;

is identical to

(parameter){
  return expression;
}
  • Related