Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Todo title & state in constructor

  • Loading branch information...
commit 2f2c3b5d9dca286bb9d9d0f3598e76b1b7f3e880 1 parent 1c8b2d6
@MathieuLorber authored
Showing with 6 additions and 7 deletions.
  1. +6 −7 labs/architecture-examples/dart/dart/todoApp.dart
View
13 labs/architecture-examples/dart/dart/todoApp.dart
@@ -16,6 +16,7 @@ class Todo {
int id;
String title;
bool completed;
+ Todo(this.title, this.completed);
}
void main() {
@@ -23,9 +24,9 @@ void main() {
newTodoElement.on.keyPress.add((KeyboardEvent e) {
if(e.keyIdentifier == KeyName.ENTER) {
- String content = newTodoElement.value.trim();
- if(content != '') {
- addTodo(content);
+ String title = newTodoElement.value.trim();
+ if(title != '') {
+ addTodo(title);
newTodoElement.value = '';
updateFooterDisplay();
}
@@ -58,10 +59,8 @@ void main() {
updateFooterDisplay();
}
-void addTodo(String content, [bool complete = false]) {
- Todo todo = new Todo();
- todo.completed = complete;
- todo.title = content;
+void addTodo(String title, [bool completed = false]) {
+ Todo todo = new Todo(title, completed);
TodoElement todoElement = new TodoElement(todo);
todoElements.add(todoElement);
Please sign in to comment.
Something went wrong with that request. Please try again.