-1

In Flutter, Data calculation takes time to compute. how to wait for non-future function to complete? Local Data manipulation takes time to complete. how to assign it as a future or wait for the local function to complete?

Anand A L
  • 87
  • 2
  • 7
  • If your function is *synchronous*, you don't have any choice *but* to wait; execution will not return to the caller until the function completes. If the function is *asynchronous*, then it *should* return a `Future`. If the function is asynchronous but does not return a `Future`, then it's a fire-and-forget function, and there's no general way for callers to wait for it to complete. If you're asking how to make a time-consuming, synchronous function asynchronous, it might depend on exactly what you're doing, but in general you'd probably have to do the work in a separate `Isolate`. – jamesdlin Dec 05 '20 at 08:29

1 Answers1

0

You'll need to get it off the UI thread, and on to its own Isolate. Look in particular at Isolate.spawn for running code in a separate thread.

Randal Schwartz
  • 39,428
  • 4
  • 43
  • 70