Skip to content

Instantly share code, notes, and snippets.

@mrmitew
Created October 9, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrmitew/e8e0bc6f53d9079e6013c2228b8c5cfe to your computer and use it in GitHub Desktop.
Save mrmitew/e8e0bc6f53d9079e6013c2228b8c5cfe to your computer and use it in GitHub Desktop.
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