gradualValue function

double gradualValue(
  1. num input,
  2. num target, {
  3. double power = 0.5,
})

Input a value and a target, get a output between 0.0 and 1.0. The more the input is near the target, the more the output is near 1.0.

Implementation

double gradualValue(num input, num target, {double power = 0.5}) {
  input = input.clamp(0, target);
  final ratio = input / target;
  return math.pow(ratio, 1 / power).toDouble();
}