Skip to content

Instantly share code, notes, and snippets.

@bluemix
Created April 13, 2019 11:10
Show Gist options
  • Save bluemix/16fa1f6a30540c36c3a806eba711b8d2 to your computer and use it in GitHub Desktop.
Save bluemix/16fa1f6a30540c36c3a806eba711b8d2 to your computer and use it in GitHub Desktop.
TranslateTransition for Flutter
class TranslateTransition extends AnimatedWidget {
const TranslateTransition({
Key key,
@required Animation<double> translate,
this.alignment = Alignment.center,
this.child,
}) : super(key: key, listenable: translate);
Animation<double> get translate => listenable;
final Alignment alignment;
final Widget child;
@override
Widget build(BuildContext context) {
final double translateValue = translate.value;
final Matrix4 transform = Matrix4.identity()
// ..translate(translateValue, translateValue, 1.0);
..translate(translateValue);
return Transform(
transform: transform,
alignment: alignment,
child: child,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment