waitWhile method

Future waitWhile(
  1. bool test(), [
  2. Duration pollInterval = Duration.zero
])

this is a check that ensures the sort is ended!

Implementation

Future waitWhile(bool Function() test,
    [Duration pollInterval = Duration.zero]) {
  var completer = Completer();
  check() {
    if (test()) {
      completer.complete();
    } else {
      Timer(pollInterval, check);
    }
  }

  check();
  return completer.future;
}