Last active
August 30, 2018 18:14
-
-
Save kwalrath/2a24f3f042f1c86cf91621c30adce771 to your computer and use it in GitHub Desktop.
webdev example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h2>A Simple To-Do List</h2> | |
| <p>Things to do:</p> | |
| <ul id="todolist"> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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