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

后端 未结 4 861
抹茶落季
抹茶落季 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:21

    You can simply use the Futurevalue factory constructor:

    return Future.value('Back to the future!');
    

提交回复
热议问题