You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.4 KiB

import 'package:flutter/material.dart';
class RotateContainer extends StatefulWidget {
final bool rotated;
final Widget? child;
RotateContainer({this.child, this.rotated = false});
@override
State<StatefulWidget> createState() {
return _RotateContainer();
}
}
class _RotateContainer extends State<RotateContainer>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
startAnimation();
}
startAnimation() {
_controller = AnimationController(vsync: this, duration: Duration(seconds: 1));
_controller.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_controller.reset();
_controller.forward();
} else if (status == AnimationStatus.dismissed) {
print("status is dismissed");
} else if (status == AnimationStatus.forward) {
print("status is forward");
} else if (status == AnimationStatus.reverse) {
print("status is reverse");
}
});
if (widget.rotated) {
_controller.forward();
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return RotationTransition(
alignment: Alignment.center,
turns: _controller,
child: widget.child,
);
}
}