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

Notifying the user of an update

However impressive a created display is it is unlikely to hold the user's attention forever and they are likely to switch to another application or browser tab. Luckily, HTML5 has a feature that will allow notifications on the desktop.

The main.dart function quakeUpdate checks if there is a significant update to notify the user about. To determine which item in the list to notify the user about, the lastWhere method is used. This List method finds the last item in the list that matches the criteria defined by the supplied function. In this case, we look at each feature's magnitude value (stored in gf[2]) and return true or false if the value meets the threshold:

quakeUpdate([Timer t = null]) async { await featPlotter.updateData(); ...

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