Complete Code FOr Repeat Same Animation In Flutter
main.dart
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
home: RepeatAnimation(),
);
}
}
class RepeatAnimation extends StatefulWidget {
@override
_RepeatAnimationState createState() => _RepeatAnimationState();
}
class _RepeatAnimationState extends State<RepeatAnimation>
with SingleTickerProviderStateMixin {
AnimationController animationController;
Animation<double> animation;
@override
void initState() {
super.initState();
animationController = AnimationController(
vsync: this,
duration: Duration(seconds: 5),
)..addListener(() => setState(() {}));
animation = Tween<double>(
begin: 50.0,
end: 200.0,
).animate(animationController);
animationController.forward();
animation.addStatusListener((status) {
if (status == AnimationStatus.completed) {
animationController.repeat();
}
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.indigo,
title: Text("Repeat Same Animation")),
body: Center(
child: Container(
child: Center(
child: Text("BajarangiSoft.com",style:
TextStyle(color: Colors.white,fontSize: 18
)),
),
color: Colors.indigo,
height: animation.value,
width: animation.value,
),
),
);
}
}