Created
April 13, 2019 11:10
-
-
Save bluemix/16fa1f6a30540c36c3a806eba711b8d2 to your computer and use it in GitHub Desktop.
TranslateTransition for Flutter
This file contains 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
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