Unverified Commit 379a4e73 authored by ny927's avatar ny927 Committed by GitHub

Add sample code to DefaultTextStyleTransition (#64638)

parent 7eb84474
...@@ -1310,6 +1310,51 @@ class AlignTransition extends AnimatedWidget { ...@@ -1310,6 +1310,51 @@ class AlignTransition extends AnimatedWidget {
/// Animated version of a [DefaultTextStyle] that animates the different properties /// Animated version of a [DefaultTextStyle] that animates the different properties
/// of its [TextStyle]. /// 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: /// See also:
/// ///
/// * [AnimatedDefaultTextStyle], which animates changes in text style without /// * [AnimatedDefaultTextStyle], which animates changes in text style without
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment