StutterDetectStrategy constructor
StutterDetectStrategy({
- Duration stutterThreshold = _defaultStutterThreshold,
- void onStutterDetected(
- StutterInfo info
- @visibleForTesting int nowMillisProvider()?,
创建卡顿检测策略
stutterThreshold Loading duration threshold for stutter detection.
Defaults to 500ms.
onStutterDetected Optional callback for stutter events.
nowMillisProvider 时间源,必须返回正值(默认 DateTime.now().millisecondsSinceEpoch)。
Implementation
StutterDetectStrategy({
this.stutterThreshold = _defaultStutterThreshold,
this.onStutterDetected,
@visibleForTesting int Function()? nowMillisProvider,
}) : _nowMillisProvider = nowMillisProvider ?? _defaultNowMillis {
assert(
nowMillisProvider == null || nowMillisProvider() > 0,
'nowMillisProvider must return positive values',
);
}