length method
Returns keys length.
Implementation
@override
FutureOr<int> length({Duration? timeout, bool refresh = false}) {
var now = DateTime.now();
if (refresh) {
var length = _sharedMap.length();
return _cacheKeysLength(length, now);
}
var keysLengthCached = _keysLengthCached;
if (keysLengthCached != null) {
timeout ??= this.timeout;
var elapsedTime = now.difference(keysLengthCached.$1);
if (elapsedTime <= timeout) {
return keysLengthCached.$2;
}
}
var lengthAsync = _lengthAsync;
if (lengthAsync != null) {
return lengthAsync;
}
var length = _sharedMap.length();
return _cacheKeysLength(length, now);
}