@@ -21,11 +21,12 @@ class SpinKitDancingSquare extends StatefulWidget {
2121 final AnimationController ? controller;
2222
2323 @override
24- _SpinKitDancingSquareState createState () => _SpinKitDancingSquareState ();
24+ State < SpinKitDancingSquare > createState () => _SpinKitDancingSquareState ();
2525}
2626
2727class _SpinKitDancingSquareState extends State <SpinKitDancingSquare > with SingleTickerProviderStateMixin {
28- final List <double > delays = [.0 , - 1.1 , - 1.0 , - 0.9 , - 0.8 , - 0.7 , - 0.6 , - 0.5 , - 0.4 , - 0.3 , - 0.2 , - 0.1 ];
28+ static const _itemCount = 12 ;
29+
2930 late AnimationController _controller;
3031
3132 @override
@@ -49,19 +50,20 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
4950 child: SizedBox .fromSize (
5051 size: Size .square (widget.size),
5152 child: Stack (
52- children: List .generate (delays.length, (index) {
53- final _position = widget.size * .5 ;
53+ children: List .generate (_itemCount, (index) {
54+ final position = widget.size * .5 ;
55+ final delay = index / _itemCount;
5456 return Stack (
5557 children: [
5658 Positioned .fill (
57- left: _position ,
58- top: _position ,
59+ left: position ,
60+ top: position ,
5961 child: Transform (
6062 transform: Matrix4 .rotationX (30.0 * index * 0.0174533 ),
6163 child: Align (
6264 alignment: Alignment .center,
6365 child: ScaleTransition (
64- scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delays[index] ).animate (_controller),
66+ scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delay ).animate (_controller),
6567 child: SizedBox .fromSize (
6668 size: Size .square (widget.size * 0.15 ),
6769 child: _itemBuilder (index),
@@ -71,14 +73,14 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
7173 ),
7274 ),
7375 Positioned .fill (
74- left: _position ,
75- top: - 1 * _position ,
76+ left: position ,
77+ top: - 1 * position ,
7678 child: Transform (
7779 transform: Matrix4 .rotationY (30.0 * index * 0.0174533 ),
7880 child: Align (
7981 alignment: Alignment .center,
8082 child: ScaleTransition (
81- scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delays[index] ).animate (_controller),
83+ scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delay ).animate (_controller),
8284 child: SizedBox .fromSize (
8385 size: Size .square (widget.size * 0.15 ),
8486 child: _itemBuilder (index),
@@ -88,14 +90,14 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
8890 ),
8991 ),
9092 Positioned .fill (
91- left: - 1 * _position ,
92- top: _position ,
93+ left: - 1 * position ,
94+ top: position ,
9395 child: Transform (
9496 transform: Matrix4 .rotationX (30.0 * index * 0.0174533 ),
9597 child: Align (
9698 alignment: Alignment .center,
9799 child: ScaleTransition (
98- scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delays[index] ).animate (_controller),
100+ scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delay ).animate (_controller),
99101 child: SizedBox .fromSize (
100102 size: Size .square (widget.size * 0.15 ),
101103 child: _itemBuilder (index),
@@ -105,14 +107,14 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
105107 ),
106108 ),
107109 Positioned .fill (
108- left: _position ,
109- top: _position ,
110+ left: position ,
111+ top: position ,
110112 child: Transform (
111113 transform: Matrix4 .rotationY (30.0 * index * 0.0174533 ),
112114 child: Align (
113115 alignment: Alignment .center,
114116 child: ScaleTransition (
115- scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delays[index] ).animate (_controller),
117+ scale: DelayTween (begin: 0.0 , end: 1.0 , delay: delay ).animate (_controller),
116118 child: SizedBox .fromSize (
117119 size: Size .square (widget.size * 0.15 ),
118120 child: _itemBuilder (index),
0 commit comments