Skip to content

Commit 49f48ff

Browse files
authored
Add sample code to RotationTransition (flutter#64795)
1 parent adc5f26 commit 49f48ff

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

packages/flutter/lib/src/widgets/transitions.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,52 @@ class ScaleTransition extends AnimatedWidget {
417417
/// Here's an illustration of the [RotationTransition] widget, with it's [turns]
418418
/// animated by a [CurvedAnimation] set to [Curves.elasticOut]:
419419
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/rotation_transition.mp4}
420+
///
421+
/// {@tool dartpad --template=stateful_widget_material_ticker}
422+
///
423+
/// The following code implements the [RotationTransition] as seen in the video
424+
/// above:
425+
///
426+
/// ```dart
427+
/// AnimationController _controller;
428+
/// Animation<double> _animation;
429+
///
430+
/// @override
431+
/// void initState() {
432+
/// super.initState();
433+
/// _controller = AnimationController(
434+
/// duration: const Duration(seconds: 2),
435+
/// vsync: this,
436+
/// )..repeat(reverse: true);
437+
/// _animation = CurvedAnimation(
438+
/// parent: _controller,
439+
/// curve: Curves.elasticOut,
440+
/// );
441+
/// }
442+
///
443+
/// @override
444+
/// void dispose() {
445+
/// _controller.dispose();
446+
/// super.dispose();
447+
/// }
448+
///
449+
/// @override
450+
/// Widget build(BuildContext context) {
451+
/// return Scaffold(
452+
/// body: Center(
453+
/// child: RotationTransition(
454+
/// turns: _animation,
455+
/// child: const Padding(
456+
/// padding: EdgeInsets.all(8.0),
457+
/// child: FlutterLogo(size: 150.0),
458+
/// ),
459+
/// ),
460+
/// ),
461+
/// );
462+
/// }
463+
/// ```
464+
/// {@end-tool}
465+
///
420466
/// See also:
421467
///
422468
/// * [ScaleTransition], a widget that animates the scale of a transformed

0 commit comments

Comments
 (0)