From 379a4e73154c1f325f6f6a086cb6725826e60f60 Mon Sep 17 00:00:00 2001 From: ny927 <32477115+ny927@users.noreply.github.com> Date: Wed, 23 Sep 2020 04:02:05 +0900 Subject: [PATCH] Add sample code to DefaultTextStyleTransition (#64638) --- .../flutter/lib/src/widgets/transitions.dart | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) 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