How to rotate an Image in flutter? Explicit Animations - RotationTransition widget

This Article is posted by seven.srikanth at 1/27/2020 6:01:33 AM



RotationTransition widget can be used to Animate a rotation of a widget. 
Here's an illustration of the RotationTransition widget and output of this example program.
Here is an example on RotationTransition in Flutter. Copy the code to main.dart file and run it to see the output. 

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@ override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'RotationTransition Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
final String? title;
const MyHomePage({Key? key, this.title}) : super(key: key);
@ override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@ override
void initState() {
super.initState();
_controller =
AnimationController(duration: Duration(seconds: 15), vsync: this)
..repeat();
}
@ override
void dispose() {
super.dispose();
}
@ override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title as String),
),
body: Center(
child: RotationTransition(
alignment: Alignment.center,
turns: _controller,
child: FlutterLogo(
size: 100.0,
),
)));
}
}
Thanks,
Srikanth

Tags: RotationTransition; Rotate widget;








0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.


© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com