Skip to content

Instantly share code, notes, and snippets.

@ericguzman
Last active March 27, 2020 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericguzman/662c4dfc257c2c99aeb0766150f012c8 to your computer and use it in GitHub Desktop.
Save ericguzman/662c4dfc257c2c99aeb0766150f012c8 to your computer and use it in GitHub Desktop.
Simple dart html
<h2>A Simple To-Do List</h2>
<p>Things to do:</p>
<ul id="todolist">
</ul>
import 'dart:html';
Iterable<String> thingsTodo() sync* {
var actions = ['Walk', 'Wash', 'Feed'];
var pets = ['cats', 'dogs'];
for (var action in actions) {
for (var pet in pets) {
if (pet == 'cats' && action != 'Feed') continue;
yield '$action the $pet';
}
}
}
void addTodoItem(String item) {
print(item);
var listElement = LIElement();
listElement.text = item;
todoList.children.add(listElement);
}
UListElement todoList;
void main() {
todoList = querySelector('#todolist');
thingsTodo().forEach(addTodoItem);
}
body {
font-family: Helvetica, sans-serif;
color: white;
padding: 24px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment