Skip to content

Instantly share code, notes, and snippets.

@matanlurey
Created July 4, 2017 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matanlurey/e69f44e94126048a37a50039e9576c2c to your computer and use it in GitHub Desktop.
Save matanlurey/e69f44e94126048a37a50039e9576c2c to your computer and use it in GitHub Desktop.
An example of using dart:html
<html>
<body>
<div id="todo-list"></div>
</body>
<script type="application/dart" src="main.dart"></script>
<script src="packages/browser/dart.js"></script>
</html>
import 'dart:html';
main() {
final sundays = const [
'sleep in',
'eat brunch',
'wash car',
];
document.querySelector('#todo-list')
..append(new UListElement()
..children.addAll(
sundays.map(_createListItem),
));
}
Element _createListItem(String item) {
final li = new LIElement();
final button = new ButtonElement()
..text = 'Done'
..onClick.listen((_) => li.remove());
li
..appendText(item)
..append(button);
return li;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment