Я хочу попросить пользователя о функции обратного вызова (сокращенно):
Future<dynamic> myfunc(dynamic onSuccess) async {
Completer c = Completer();
// some time-consuming procedure
if (onSuccess is Function) {
c.complete(true);
return c.future.then(onSuccess());
} else {
c.complete(false);
return c.future;
}
}
bool should_be_true = await myfunc(print("Success!"))
Но мой код не работает, dartanalyzer выдает следующую ошибку в последней строке:
error • The expression here has a type of 'void', and therefore cannot be used at example/index.dart:15:35 • use_of_void_result