Skip to content

Instantly share code, notes, and snippets.

@hectorAguero
Created February 20, 2025 21:03
Show Gist options
  • Save hectorAguero/8277382b08ea23709a569503ac716e91 to your computer and use it in GitHub Desktop.
Save hectorAguero/8277382b08ea23709a569503ac716e91 to your computer and use it in GitHub Desktop.
Arrow Rotation
import 'package:flutter/material.dart';
/// Flutter code sample for [RotationTransition].
void main() => runApp(const RotationTransitionExampleApp());
class RotationTransitionExampleApp extends StatelessWidget {
const RotationTransitionExampleApp({super.key});
@override
Widget build(BuildContext context) => const MaterialApp(home: RotationTransitionExample(),);
}
class RotationTransitionExample extends StatefulWidget {
const RotationTransitionExample({super.key});
@override
State<RotationTransitionExample> createState() =>
_RotationTransitionExampleState();
}
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
class _RotationTransitionExampleState extends State<RotationTransitionExample>
with TickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..reverse(from: 0.5);
late final Animation<double> _animation = CurvedAnimation(
parent: _controller,
curve: Curves.linear,
);
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => Scaffold(
body: Center(
child: RotationTransition(
turns: _animation,
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.arrow_upward_rounded),
),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment