In flutter, we can declare a function as variable and call it like this
MyWidget((){print('HI');});
class MyWidget extends StatelessWidget{
final Function sayHi;
MyWidget(this.sayHi);
@override
Widget build(BuildContext context) {
sayHi();
return ...
}
}
But what if sayHi() is a async function? How to declare a async function as variable? There seems no class like AsyncFunction. So how to achive that?