Last active
March 27, 2020 05:49
-
-
Save ericguzman/662c4dfc257c2c99aeb0766150f012c8 to your computer and use it in GitHub Desktop.
Simple dart html
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); | |
} |
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
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