From 49f48ff224defec59d55a49d9538737f96c45aad Mon Sep 17 00:00:00 2001 From: AhHyun Choi Date: Wed, 9 Sep 2020 08:05:03 +0900 Subject: [PATCH] Add sample code to RotationTransition (#64795) --- .../flutter/lib/src/widgets/transitions.dart | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 2fb135c664..fa0398475c 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -417,6 +417,52 @@ class ScaleTransition extends AnimatedWidget { /// Here's an illustration of the [RotationTransition] widget, with it's [turns] /// animated by a [CurvedAnimation] set to [Curves.elasticOut]: /// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/rotation_transition.mp4} +/// +/// {@tool dartpad --template=stateful_widget_material_ticker} +/// +/// The following code implements the [RotationTransition] as seen in the video +/// above: +/// +/// ```dart +/// AnimationController _controller; +/// Animation _animation; +/// +/// @override +/// void initState() { +/// super.initState(); +/// _controller = AnimationController( +/// duration: const Duration(seconds: 2), +/// vsync: this, +/// )..repeat(reverse: true); +/// _animation = CurvedAnimation( +/// parent: _controller, +/// curve: Curves.elasticOut, +/// ); +/// } +/// +/// @override +/// void dispose() { +/// _controller.dispose(); +/// super.dispose(); +/// } +/// +/// @override +/// Widget build(BuildContext context) { +/// return Scaffold( +/// body: Center( +/// child: RotationTransition( +/// turns: _animation, +/// child: const Padding( +/// padding: EdgeInsets.all(8.0), +/// child: FlutterLogo(size: 150.0), +/// ), +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [ScaleTransition], a widget that animates the scale of a transformed