How is whenCompleted() different from then() in Future?

Technology CommunityCategory: FlutterHow is whenCompleted() different from then() in Future?
VietMX Staff asked 3 years ago
  • .whenComplete will fire a function either when the Future completes with an error or not, while .then returns a new Future which is completed with the result of the call to onValue (if this future completes with a value) or to onError (if this future completes with an error)
  • .whenCompleted is the asynchronous equivalent of a “finally” block.