O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Timing the presentation

The presenter will want to keep to their allotted time slot. We will include a timer in the editor to aid in rehearsal.

Introducing the Stopwatch class

The Stopwatch class (from dart:core) provides much of the functionality needed for this feature, as shown in this small command-line application:

main() {
  Stopwatch sw = new Stopwatch();
  sw.start();
  print(sw.elapsed);
  sw.stop();
  print(sw.elapsed);
}

The elapsed property can be checked at any time to give the current duration. This is a very useful class as, for example, it can be used to compare different functions to see which is the fastest.

Implementing the presentation timer

The clock will be stopped and started with a single button handled by the toggleTimer method. A recurring ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required