I create an animation for a container with a rotation forward and reverse, I want the reverse animation is longer than forward animation how can I do?
import 'dart:math'as math;
import 'package:flutter/material.dart';
class AnimationPage extends StatefulWidget {
@override
_AnimationPageState createState() => _AnimationPageState();
}
class _AnimationPageState extends State<AnimationPage>
with TickerProviderStateMixin {
AnimationController animController;
Animation<double> animation;
@override
void initState() {
// TODO: implement initState
super.initState();
animController =
AnimationController(duration: Duration(seconds: 5), vsync: this);
animation= Tween<double>(
begin: 0, end: 2* math.pi,
).animate(animController)
..addListener((){
setState((){});
})
..addStatusListener((status) {
if(status == AnimationStatus.completed){
animController.reverse();
} else if(status == AnimationStatus.dismissed){
animController.forward();
}
});
animController.forward();
Just add a reverseDuration
parameter to the AnimationController
like:
animController = AnimationController(
duration: Duration(seconds: 5),
reverseDuration: Duration(seconds: 8),
vsync: this,
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With