Turn off AnimationControllers when not in use (#5902)

This requires all AnimationController objects to be given a
TickerProvider, a class that can create the Ticker.

It also provides some nice mixins for people who want to have their
State provide a TickerProvider. And a schedulerTickerProvider for those
cases where you just want to see your battery burn.

Also, we now enforce destruction order for elements.
This commit is contained in:
Ian Hickson
2016-09-26 10:57:10 -07:00
committed by GitHub
parent c825237a38
commit 9e673853e5
63 changed files with 1358 additions and 492 deletions

View File

@@ -9,7 +9,7 @@ class SpinningSquare extends StatefulWidget {
_SpinningSquareState createState() => new _SpinningSquareState();
}
class _SpinningSquareState extends State<SpinningSquare> {
class _SpinningSquareState extends State<SpinningSquare> with SingleTickerProviderStateMixin {
AnimationController _animation;
@override
@@ -19,7 +19,8 @@ class _SpinningSquareState extends State<SpinningSquare> {
// represents an entire turn of the square whereas in the other examples
// we used 0.0 -> math.PI, which is only half a turn.
_animation = new AnimationController(
duration: const Duration(milliseconds: 3600)
duration: const Duration(milliseconds: 3600),
vsync: this,
)..repeat();
}