1

I want to write a asynchronous function as a synchronous function without Future.then and await,

like Flutter File's delete api

new File(path).deleteSync();

But I do not know how to write.

Thank you.

dev-aentgs
  • 1,218
  • 2
  • 9
  • 17
  • 2
    If you cannot write a synchronous function because the function you call are asynchronous, then trying to squeeze it into a synchronous function is probably not best practice. Maybe you can ask about your case and what you want to achieve? Why do you need a synchronous function? – nvoigt Jun 24 '20 at 10:28
  • Like @nvoigt said. Also the ```deleteSync()``` it's a bad example here and it might confuse you. ```deleteSync``` doesn't use ```deleteAsync``` and makes it ```synced```. It's just a different implementation. – danypata Jun 24 '20 at 12:26
  • 1
    https://stackoverflow.com/questions/28238161/how-to-make-an-asynchronous-dart-call-synchronous – jnnks Jun 24 '20 at 13:29

0 Answers0