1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2025-11-08 20:50:04 +00:00

Add new flutter example of todo app with provider (#78)

This commit is contained in:
Rene Lazo Mendez
2021-07-25 14:51:35 -04:00
committed by GitHub
parent dd23466cd4
commit 89f48b8f1e
74 changed files with 1637 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_new_provider_todo/models/todo.dart';
/// This class represents a model
/// that notify listeners when it has some changes
class TodoList extends ChangeNotifier {
List<Todo> _list = new List<Todo>();
List<Todo> get list => _list;
void add(Todo newItem) {
this._list.add(newItem);
notifyListeners();
}
void remove(Todo removedItem) {
this._list.remove(removedItem);
notifyListeners();
}
void clearDoneItems() {
this._list.removeWhere((Todo element) => element.done);
notifyListeners();
}
}