waitStatus method Null safety

FutureOr<IsoBridgeStatus> waitStatus(
  1. int msecs,
  2. [IsoBridgeStatus ref = IsoBridgeStatus.none]
)

Implementation

FutureOr<IsoBridgeStatus> waitStatus(
  int msecs, [
  IsoBridgeStatus ref = IsoBridgeStatus.none,
]) async {
  var current = _status;
  if (current == ref) {
    return current;
  }
  if (_errors.isNotEmpty) {
    return IsoBridgeStatus.error;
  }
  var total = 0;
  while (_status != ref) {
    await Future.delayed(Duration(milliseconds: 10));
    if (_errors.isNotEmpty) {
      return IsoBridgeStatus.error;
    }
    total += 10;
    if (total <= msecs) {
      continue;
    }
    return IsoBridgeStatus.nochange;
  }
  return _status;
}