whenOnline static method
Completes as soon as the device is online (immediately if it already is).
Throws TimeoutException after timeout, when given.
Implementation
static Future<void> whenOnline({Duration? timeout}) {
if (isOnline) return Future<void>.value();
final Future<void> online = onlineStream.firstWhere((bool v) => v);
return timeout == null ? online : online.timeout(timeout);
}