waitWhile method
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;
}