Skip to content

Instantly share code, notes, and snippets.

@ndungudedan
Created May 14, 2022 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndungudedan/8516ae7f37ec3b2c2e68787fe706f23e to your computer and use it in GitHub Desktop.
Save ndungudedan/8516ae7f37ec3b2c2e68787fe706f23e to your computer and use it in GitHub Desktop.
/// 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