Junior — Middle
Can you explain what AnimationController is and how it is used in Flutter for managing animations?
sobes.tech AI
Answer from AI
AnimationController in Flutter is a class that manages animations by controlling their duration, progress, and state. It generates values from 0.0 to 1.0 over a specified time, which can be used to modify widget properties (such as size, color, position).
Example usage:
AnimationController controller = AnimationController(
duration: const Duration(seconds: 2),
vsync: this, // usually a State with SingleTickerProviderStateMixin
);
controller.forward(); // Start the animation
// In a widget, you can listen to the controller and update the UI
Thus, AnimationController serves as the foundation for creating smooth and controllable animations in Flutter applications.