Add sample code to DefaultTextStyleTransition (#64638)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user