setPercent method

(ProgressModel, Cmd?) setPercent(
  1. double p, {
  2. bool animate = true,
})

Sets the target percentage and returns a command for animation.

Implementation

(ProgressModel, Cmd?) setPercent(double p, {bool animate = true}) {
  final clamped = p.clamp(0.0, 1.0);
  final newModel = copyWith(targetPercent: clamped, tag: _tag + 1);
  if (!animate) {
    return (newModel.copyWith(percentShown: clamped, velocity: 0), null);
  }
  return (newModel, newModel._nextFrame());
}