Commit 35867dba authored by Brian Egan's avatar Brian Egan

Mutable everywhere in vanilla example

parent f5d2fee9
This diff is collapsed.
......@@ -33,25 +33,25 @@ class AppState {
activeTab: activeTab ?? this.activeTab,
);
AppState toggleAll() {
final allCompleted = this.allComplete;
return copyWith(
todos:
todos.map((todo) => todo.copyWith(complete: !allCompleted)).toList(),
);
}
AppState toggleOne(Todo todo, bool isComplete) {
return copyWith(
todos: todos
.map((t) => t == todo ? t.copyWith(complete: isComplete) : t)
.toList(),
);
}
AppState clearCompleted() =>
copyWith(todos: todos.where((todo) => !todo.complete).toList());
// AppState toggleAll() {
// final allCompleted = this.allComplete;
//
// return copyWith(
// todos:
// todos.map((todo) => todo.copyWith(complete: !allCompleted)).toList(),
// );
// }
//
// AppState toggleOne(Todo todo, bool isComplete) {
// return copyWith(
// todos: todos
// .map((t) => t == todo ? t.copyWith(complete: isComplete) : t)
// .toList(),
// );
// }
//
// AppState clearCompleted() =>
// copyWith(todos: todos.where((todo) => !todo.complete).toList());
bool get hasTodos => todos.isNotEmpty;
......@@ -157,25 +157,14 @@ class AppState {
}
class Todo {
final bool complete;
final String task;
final String note;
final String id;
bool complete;
String task;
String note;
String id;
Todo(this.task, {this.complete = false, this.note = '', String id})
: this.id = id ?? (new Uuid().generateV4());
Todo copyWith({
String task,
bool complete,
String note,
String id,
}) =>
new Todo(task ?? this.task,
complete: complete ?? this.complete,
note: note ?? this.note,
id: id ?? this.id);
Map<String, Object> toJson() {
return {
"complete": complete,
......
......@@ -14,6 +14,7 @@ class FlutterMvcStrings {
static final String editTodo = "Edit Todo";
static final String saveChanges = "Save changes";
static final String filterTodos = "Filter todos";
static final String deleteTodo = "Delete Todo";
static String itemsLeft(int numTodos) {
return '$numTodos item${numTodos != 1 ? 's' : ''} left';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment