diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 012a6cf711..152680f7b9 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -1310,6 +1310,51 @@ class AlignTransition extends AnimatedWidget { /// Animated version of a [DefaultTextStyle] that animates the different properties /// of its [TextStyle]. /// +/// {@tool dartpad --template=stateful_widget_material_ticker} +/// +/// The following code implements the [DefaultTextStyleTransition] that shows +/// a transition between thick blue font and thin red font. +/// +/// ```dart +/// AnimationController _controller; +/// TextStyleTween _styleTween; +/// CurvedAnimation _curvedAnimation; +/// +/// @override +/// void initState() { +/// super.initState(); +/// _controller = AnimationController( +/// duration: const Duration(seconds: 2), +/// vsync: this, +/// )..repeat(reverse: true); +/// _styleTween = TextStyleTween( +/// begin: TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900), +/// end: TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100), +/// ); +/// _curvedAnimation = CurvedAnimation( +/// parent: _controller, +/// curve: Curves.elasticInOut, +/// ); +/// } +/// +/// @override +/// void dispose() { +/// _controller.dispose(); +/// super.dispose(); +/// } +/// +/// @override +/// Widget build(BuildContext context) { +/// return Center( +/// child: DefaultTextStyleTransition( +/// style: _styleTween.animate(_curvedAnimation), +/// child: Text('Flutter'), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [AnimatedDefaultTextStyle], which animates changes in text style without