Unverified Commit 3905d991 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Minor doc improvements. (#13969)

parent 9114e2af
...@@ -211,6 +211,15 @@ class AnimationController extends Animation<double> ...@@ -211,6 +211,15 @@ class AnimationController extends Animation<double>
/// The most recently returned [TickerFuture], if any, is marked as having been /// The most recently returned [TickerFuture], if any, is marked as having been
/// canceled, meaning the future never completes and its [TickerFuture.orCancel] /// canceled, meaning the future never completes and its [TickerFuture.orCancel]
/// derivative future completes with a [TickerCanceled] error. /// 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) { set value(double newValue) {
assert(newValue != null); assert(newValue != null);
stop(); stop();
...@@ -221,6 +230,18 @@ class AnimationController extends Animation<double> ...@@ -221,6 +230,18 @@ class AnimationController extends Animation<double>
/// Sets the controller's value to [lowerBound], stopping the animation (if /// Sets the controller's value to [lowerBound], stopping the animation (if
/// in progress), and resetting to its beginning point, or dismissed state. /// 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() { void reset() {
value = lowerBound; value = lowerBound;
} }
...@@ -463,8 +484,15 @@ class AnimationController extends Animation<double> ...@@ -463,8 +484,15 @@ class AnimationController extends Animation<double>
/// By default, the most recently returned [TickerFuture] is marked as having /// By default, the most recently returned [TickerFuture] is marked as having
/// been canceled, meaning the future never completes and its /// been canceled, meaning the future never completes and its
/// [TickerFuture.orCancel] derivative future completes with a [TickerCanceled] /// [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. /// 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 }) { void stop({ bool canceled: true }) {
_simulation = null; _simulation = null;
_lastElapsedDuration = null; _lastElapsedDuration = null;
......
...@@ -346,7 +346,7 @@ class Ticker { ...@@ -346,7 +346,7 @@ class Ticker {
/// if the [Ticker] that returned the [TickerFuture] was stopped with `canceled` /// if the [Ticker] that returned the [TickerFuture] was stopped with `canceled`
/// set to true, or if it was disposed without being stopped. /// 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]. /// canceled, use [whenCompleteOrCancel].
class TickerFuture implements Future<Null> { class TickerFuture implements Future<Null> {
TickerFuture._(); TickerFuture._();
...@@ -381,6 +381,10 @@ class TickerFuture implements Future<Null> { ...@@ -381,6 +381,10 @@ class TickerFuture implements Future<Null> {
/// Calls `callback` either when this future resolves or when the ticker is /// Calls `callback` either when this future resolves or when the ticker is
/// canceled. /// 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) { void whenCompleteOrCancel(VoidCallback callback) {
Null thunk(dynamic value) { Null thunk(dynamic value) {
callback(); callback();
...@@ -391,6 +395,12 @@ class TickerFuture implements Future<Null> { ...@@ -391,6 +395,12 @@ class TickerFuture implements Future<Null> {
/// A future that resolves when this future resolves or throws when the ticker /// A future that resolves when this future resolves or throws when the ticker
/// is canceled. /// 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<Null> get orCancel { Future<Null> get orCancel {
if (_secondaryCompleter == null) { if (_secondaryCompleter == null) {
_secondaryCompleter = new Completer<Null>(); _secondaryCompleter = new Completer<Null>();
...@@ -443,7 +453,7 @@ class TickerCanceled implements Exception { ...@@ -443,7 +453,7 @@ class TickerCanceled implements Exception {
/// Reference to the [Ticker] object that was canceled. /// Reference to the [Ticker] object that was canceled.
/// ///
/// This may be null in the case that the [Future] created for /// 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; final Ticker ticker;
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment