diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index 32ab062ff1..537efffd19 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -211,6 +211,15 @@ class AnimationController extends Animation /// The most recently returned [TickerFuture], if any, is marked as having been /// canceled, meaning the future never completes and its [TickerFuture.orCancel] /// derivative future completes with a [TickerCanceled] error. + /// + /// See also: + /// + /// * [reset], which is equivalent to setting [value] to [lowerBound]. + /// * [stop], which aborts the animation without changing its value or status + /// and without dispatching any notifications other than completing or + /// canceling the [TickerFuture]. + /// * [forward], [reverse], [animateTo], [animateWith], [fling], and [repeat], + /// which start the animation controller. set value(double newValue) { assert(newValue != null); stop(); @@ -221,6 +230,18 @@ class AnimationController extends Animation /// Sets the controller's value to [lowerBound], stopping the animation (if /// in progress), and resetting to its beginning point, or dismissed state. + /// + /// The most recently returned [TickerFuture], if any, is marked as having been + /// canceled, meaning the future never completes and its [TickerFuture.orCancel] + /// derivative future completes with a [TickerCanceled] error. + /// + /// See also: + /// + /// * [value], which can be explicitly set to a specific value as desired. + /// * [forward], which starts the animation in the forward direction. + /// * [stop], which aborts the animation without changing its value or status + /// and without dispatching any notifications other than completing or + /// canceling the [TickerFuture]. void reset() { value = lowerBound; } @@ -463,8 +484,15 @@ class AnimationController extends Animation /// By default, the most recently returned [TickerFuture] is marked as having /// been canceled, meaning the future never completes and its /// [TickerFuture.orCancel] derivative future completes with a [TickerCanceled] - /// error. By passing the `completed` argument with the value false, this is + /// error. By passing the `canceled` argument with the value false, this is /// reversed, and the futures complete successfully. + /// + /// See also: + /// + /// * [reset], which stops the animation and resets it to the [lowerBound], + /// and which does send notifications. + /// * [forward], [reverse], [animateTo], [animateWith], [fling], and [repeat], + /// which restart the animation controller. void stop({ bool canceled: true }) { _simulation = null; _lastElapsedDuration = null; diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index 4b83c4ae21..b5ce28d47a 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -346,7 +346,7 @@ class Ticker { /// if the [Ticker] that returned the [TickerFuture] was stopped with `canceled` /// set to true, or if it was disposed without being stopped. /// -/// To run a callback when either this future resolves or when the tricker is +/// To run a callback when either this future resolves or when the ticker is /// canceled, use [whenCompleteOrCancel]. class TickerFuture implements Future { TickerFuture._(); @@ -381,6 +381,10 @@ class TickerFuture implements Future { /// Calls `callback` either when this future resolves or when the ticker is /// canceled. + /// + /// Calling this method registers an exception handler for the [orCancel] + /// future, so even if the [orCancel] property is accessed, canceling the + /// ticker will not cause an uncaught exception in the current zone. void whenCompleteOrCancel(VoidCallback callback) { Null thunk(dynamic value) { callback(); @@ -391,6 +395,12 @@ class TickerFuture implements Future { /// A future that resolves when this future resolves or throws when the ticker /// is canceled. + /// + /// If this property is never accessed, then canceling the ticker does not + /// throw any exceptions. Once this property is accessed, though, if the + /// corresponding ticker is canceled, then the [Future] returned by this + /// getter will complete with an error, and if that error is not caught, there + /// will be an uncaught exception in the current zone. Future get orCancel { if (_secondaryCompleter == null) { _secondaryCompleter = new Completer(); @@ -443,7 +453,7 @@ class TickerCanceled implements Exception { /// Reference to the [Ticker] object that was canceled. /// /// This may be null in the case that the [Future] created for - /// [TickerFuture.orCancel] was created after the future was canceled. + /// [TickerFuture.orCancel] was created after the ticker was canceled. final Ticker ticker; @override