I'm trying to add an async callback to a model in a flutter application so the model can give the view an opportunity to show some dialog before the model continues on. However, I can't seem to find an async callback. I see VoidedCallback but I don't see anything like Callback<Future>.
Add a comment
|
3 Answers
Flutter has an async version of the VoidCallback typedef, namely AsyncCallback. See: https://api.flutter.dev/flutter/foundation/AsyncCallback.html
Comments
The VoidCallback is just a signature for method callback without parameters.
typedef VoidCallback = void Function();
You can create your own:
typedef FutureCallback = void Function(Future);
Or you can just use the final Function(Function) foo = yourcallback directly.
3 Comments
David
Thanks! This worked for me:
typedef FutureCallback = Future Function();Istiaque Ahmed
can you tell in details how to use the solution ?
JJuice
I think in the above mentioned example, the async version of
VoidCallback should be typedef FutureCallback = Future<void> Function();, not void Function(Future).