waitFor method

Duration? waitFor(
  1. Duration capLeft
)

How long a late-change wait should run to see this work land, at most capLeft; null when nothing is pending inside it.

Implementation

Duration? waitFor(Duration capLeft) {
  if (httpInFlight > 0) return capLeft;
  final aged = DateTime.now().difference(readAt).inMilliseconds;
  final due = timersDueMs.map((d) => d - aged).where((d) => d > 0 && d < capLeft.inMilliseconds - _landingMs);
  if (due.isEmpty) return null;
  return Duration(milliseconds: due.reduce((a, b) => a > b ? a : b) + _landingMs);
}