How can I convert this arrow function to a normal function?

Viewed 48

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 ?

3 Answers

Try this(what I recommend ):

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

or this:

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

This might help you

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

print('Token: $value');

}));
(parameter) => expression;

is identical to

(parameter){
  return expression;
}
Related