Answers for "flutter force sync function to wait for async"

0

flutter force sync function to wait for async

Future<bool> save() async {
  // save changes async here
  return true;
}

void saveClicked() {
  saveButton.enabled = false;
  save()
    .then((success) => window.alert(success ? 'Saved' : 'Failed'))
    .catchError((e) => window.alert(e))
    .whenComplete(() { saveButton.enabled = true; });
}
Posted by: Guest on May-08-2022

Code answers related to "flutter force sync function to wait for async"

Browse Popular Code Answers by Language