readNewValue method
Reads a new value
, different from lastValue
, performing a pooling with
interval
(default: 10ms) and a timeout
(default: 10s) that checks
for a new value if needed.
Implementation
FutureOr<T?> readNewValue(
{T? lastValue,
Duration? interval,
Duration? timeout,
bool acceptsNullValue = true}) {
var value = read();
if (acceptsNullValue || value != null) {
if (lastValue == null || value != lastValue) {
return value;
}
}
interval ??= Duration(milliseconds: 10);
timeout ??= Duration(seconds: 10);
return _readNewValueImpl(lastValue, interval, timeout, acceptsNullValue);
}