Skip to content

Instantly share code, notes, and snippets.

@kwalrath
Last active August 30, 2018 18:14
Show Gist options
  • Save kwalrath/2a24f3f042f1c86cf91621c30adce771 to your computer and use it in GitHub Desktop.
Save kwalrath/2a24f3f042f1c86cf91621c30adce771 to your computer and use it in GitHub Desktop.
webdev example
<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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment