Skip to content

Instantly share code, notes, and snippets.

@ulusoyca
Last active January 29, 2022 19:49
Show Gist options
  • Save ulusoyca/401f5de1cf9ede8dfb96ea9451b27ad9 to your computer and use it in GitHub Desktop.
Save ulusoyca/401f5de1cf9ede8dfb96ea9451b27ad9 to your computer and use it in GitHub Desktop.
HeroImagePaintChildren
@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