Chapter 01 · Dart + browser APIs
Static markup, live behavior.
Hydrate an ordinary static card with JSON values, then connect its existing button to JavaScript and Dart runtime handlers.
Static template title
This static description will be hydrated from JSON.
No runtime handler has run yet.
Hydrating static HTML…
How it works
The HTML is a static template. JSON supplies values or drawing data. Dart owns rendering and browser events; boot.js registers small JavaScript handlers through LMDart.register.
final data = await fetchJson('data/hydration.json');
hydrate(document.getElementById('hydration-card')!, data);
button.onClick.listen((_) {
LMDart.call('hydrate.clicked', {'value': 'hydration'});
});