Using JavaScript in Dart
Programmers new to Dart often look for a jQuery-like library or a way to call jQuery directly from Dart. As you have already seen, Dart’s built-in DOM support obviates the need for jQuery, but there are still times when it is useful to call JavaScript from Dart. Happily, Dart makes this easy with the dart:js package.
We will talk more about libraries and packages in Chapter 10, Libraries. For now it is enough to know that we need to import the dart:js package to interact with JavaScript:
javascript/test/calling_javascript_test.dart | |
| import 'dart:js'; |
Since JavaScript throws everything into a top-level namespace, dart:js makes this available through its context property. This property provides access to top-level ...
Get Dart 1 for Everyone now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.