mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 17:35:46 +00:00
Remove indirection in Timer example
The example was originally written without a `main`, and with an example using `Duration.operator *`. An update added a call to the example method from a new `main`, removed the usage of `Duration.operator *`, but did not remove the prose reference. - Remove the sentence mentioning that the duration can be const or computed. - Remove the intermediate `scheduleTimeout` method, move the `Timer` construction to `main`. This removes any consideration of `Duration` vs `int milliseconds` which had been added in an attempt make the docs more focused on `Timer` than `Duration`. R=lrn@google.com CoreLibraryReviewExempt:Documentation change. Change-Id: I26bb4e12910eb50cf5975b8a6573701a5a862070 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330980 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Nate Bosch <nbosch@google.com>
This commit is contained in:
parent
a3c423237f
commit
d7af8ef846
|
@ -13,17 +13,11 @@ part of dart.async;
|
|||
/// A negative duration is treated the same as a duration of 0.
|
||||
/// If the duration is statically known to be 0, consider using [run].
|
||||
///
|
||||
/// Frequently the duration is either a constant or computed as in the
|
||||
/// following example (taking advantage of the multiplication operator of
|
||||
/// the [Duration] class):
|
||||
/// ```dart
|
||||
/// void main() {
|
||||
/// scheduleTimeout(5 * 1000); // 5 seconds.
|
||||
/// Timer(const Duration(seconds: 5), handleTimeout);
|
||||
/// }
|
||||
///
|
||||
/// Timer scheduleTimeout([int milliseconds = 10000]) =>
|
||||
/// Timer(Duration(milliseconds: milliseconds), handleTimeout);
|
||||
///
|
||||
/// void handleTimeout() { // callback function
|
||||
/// // Do some work.
|
||||
/// }
|
||||
|
|
Loading…
Reference in a new issue