Dart, how to create a future to return in your own functions?

后端 未结 4 943
抹茶落季
抹茶落季 2021-02-01 00:27

is it possible to create your own futures in Dart to return from your methods, or must you always return a built in future return from one of the dart async libraries methods?

4条回答
  •  无人共我
    2021-02-01 01:22

    @Fox32 has the correct answer addition to that we need to mention Type of the Completer otherwise we get exception

    Exception received is type 'Future' is not a subtype of type 'FutureOr>

    so initialisation of completer would become

    var completer= new Completer>();

提交回复
热议问题