Created
October 9, 2018 12:30
-
-
Save mrmitew/e8e0bc6f53d9079e6013c2228b8c5cfe to your computer and use it in GitHub Desktop.
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 CrossfadeTitle extends AnimatedWidget { | |
final Widget primaryTitle; | |
final Widget secondaryTitle; | |
const CrossfadeTitle({ | |
Key key, | |
Listenable listenable, | |
this.primaryTitle, | |
this.secondaryTitle, | |
}) : super(key: key, listenable: listenable); | |
@override | |
Widget build(BuildContext context) { | |
final Animation<double> animation = this.listenable; | |
return DefaultTextStyle( | |
style: Theme.of(context).primaryTextTheme.title, | |
softWrap: false, | |
overflow: TextOverflow.ellipsis, | |
child: Stack( | |
children: <Widget>[ | |
Opacity( | |
opacity: CurvedAnimation( | |
parent: ReverseAnimation(animation), | |
curve: Interval(0.5, 1.0), | |
).value, | |
child: secondaryTitle, | |
), | |
Opacity( | |
opacity: CurvedAnimation( | |
parent: animation, | |
curve: Interval(0.5, 1.0), | |
).value, | |
child: primaryTitle, | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment