Skip to content

Instantly share code, notes, and snippets.

@ulusoyca
Last active January 23, 2022 21:26
Show Gist options
  • Save ulusoyca/41e2954dc688f45d7dd561f694808375 to your computer and use it in GitHub Desktop.
Save ulusoyca/41e2954dc688f45d7dd561f694808375 to your computer and use it in GitHub Desktop.
CalculateOpacityHeroImage
final _opacityStart = 1.0;
final _opacityEnd = 0.0;
double _calculateOpacity(double currentScrollPosition) {
final double distance = heroImageHeight / 2;
final double startPoint = heroImageHeight - topBarHeight;
final rawOpacity = ((startPoint - currentScrollPosition) / distance);
return rawOpacity.clamp(_opacityEnd, _opacityStart);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment