Skip to content

Instantly share code, notes, and snippets.

@ulusoyca
Last active January 29, 2022 19:44
Show Gist options
  • Save ulusoyca/1ac7ddd5de60f2cab6df75304b938893 to your computer and use it in GitHub Desktop.
Save ulusoyca/1ac7ddd5de60f2cab6df75304b938893 to your computer and use it in GitHub Desktop.
CalculateGenericPropertChange
double calculateTransformationValue({
required double rangeInPx,
required double progressInRangeInPx,
required double startValue,
required double endValue,
}) {
final progress = progressInRangeInPx / rangeInPx;
final rawValue = startValue + (progress * (endValue - startValue));
return rawValue.clamp(min(startValue, endValue), max(startValue, endValue));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment