When I work with AnimationController it requires a vsync parameter. I have researched, should I use TickerProviderStateMixin
or SingleTickerProviderStateMixin
, currently I still do not know what is the difference between them. Thanks if you give me an explanation about it.
References:
https://api.flutter.dev/flutter/widgets/SingleTickerProviderStateMixin-mixin.html
https://api.flutter.dev/flutter/widgets/TickerProviderStateMixin-mixin.html
When you are using single AnimationController
use SingleTickerProviderStateMixin
.
If you need more than one AnimationController
use TickerProviderStateMixin
.
We need TickerProviderStateMixin
below snippet because we have two AnimationController
class _TrickerExampleState extends State<TrickerExample>
with TickerProviderStateMixin {
late AnimationController controller1;
late Animation<double> fadeAnimation;
late AnimationController controller2;
late Animation<Alignment> positionAnimation;