We want to give users the ability to choose their favorite parts of the event program. In this way, we'll also see how to write data to the Cloud Firestore database, and to query data based on specific selection criteria.
Just as we did for the EventDetail class, let's create a new model class that will contain the user's favorites, as follows:
- Let's create a new file in the models directory, called favorite.dart.
- A favorite object needs to contain an ID, the user ID (UID) of the user, and the ID of the selected event detail. We'll mark all the properties as private, and we'll create an unnamed constructor to set a new instance of a favorite, as follows:
class Favorite {
String _id;
String _eventId;
String _userId;
Favourite(this._id, this._eventId, this._userId);
}
- Then, we'll create...