ProgressGracePeriod constructor

ProgressGracePeriod({
  1. Duration defaultGracePeriod = const Duration(milliseconds: 500),
  2. Stopwatch? stopwatch,
  3. bool hasShownProgress = false,
})

Creates a ProgressGracePeriod with an optional defaultGracePeriod.

If provided, stopwatch is used to track elapsed time. It is an error if stopwatch is not running.

If hasShownProgress is true, initial progress delay is bypassed immediately.

It is an error if defaultGracePeriod is negative.

Implementation

ProgressGracePeriod({
  Duration defaultGracePeriod = const Duration(milliseconds: 500),
  Stopwatch? stopwatch,
  bool hasShownProgress = false,
}) : _defaultGracePeriod = defaultGracePeriod,
     _stopwatch = stopwatch ?? (Stopwatch()..start()),
     _hasShownProgress = hasShownProgress {
  if (defaultGracePeriod.isNegative) {
    throw ArgumentError.value(
      defaultGracePeriod,
      'defaultGracePeriod',
      'Must not be negative',
    );
  }
  if (stopwatch != null && !stopwatch.isRunning) {
    throw ArgumentError.value(stopwatch, 'stopwatch', 'Must be running');
  }
}