Last active
January 29, 2022 19:49
-
-
Save ulusoyca/401f5de1cf9ede8dfb96ea9451b27ad9 to your computer and use it in GitHub Desktop.
HeroImagePaintChildren
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
void paintChildren(FlowPaintingContext flowPaintingContext) { | |
final currentScrollPosition = scrollPosition.pixels; | |
/// Calculate scale | |
double scale = calculateTransformationValue( | |
startValue: 1.1, | |
endValue: 1.0, | |
rangeInPx: heroImageHeight - topBarHeight, | |
progressInRangeInPx: currentScrollPosition, | |
); | |
/// Calculate opacity | |
double opacity = calculateTransformationValue( | |
rangeInPx: heroImageHeight / 2, | |
progressInRangeInPx: currentScrollPosition - ((heroImageHeight / 2) - topBarHeight), | |
startValue: 1.0, | |
endValue: 0.0, | |
); | |
flowPaintingContext.paintChild( | |
0, | |
transform: Matrix4.diagonal3Values(scale, scale, 1.0), | |
opacity: opacity, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment