Dart has a single thread of execution.
Once a Dart function starts executing, it continues executing until it exits. In other words, Dart functions can’t be interrupted by other Dart code.
If populateGrid
doesn't allow the event loop to switch to the timeout
part the timeout
checks will not be executed. That means you have to break the code of populateGrid
into several part by introducing Future
computations to allow regular checks by the timeout
function.