Created
May 14, 2022 21:16
-
-
Save ndungudedan/8516ae7f37ec3b2c2e68787fe706f23e to your computer and use it in GitHub Desktop.
This file contains 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
/// The [Favorites] class holds a list of favorite items saved by the user. | |
class Favorites extends ChangeNotifier { | |
final List<Note> _favoriteItems = []; | |
List<Note> get items => _favoriteItems; | |
void add(Note note) { | |
_favoriteItems.add(note); | |
notifyListeners(); | |
} | |
void remove(int itemNo) { | |
_favoriteItems.removeAt(itemNo); | |
notifyListeners(); | |
} | |
} | |
class Note { | |
String title; | |
String description; | |
Note({required this.description, required this.title}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment