Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 656 Bytes

13.md

File metadata and controls

24 lines (18 loc) · 656 Bytes

This is time to preparing our model.

We will keep in database a word pair and a flag of like sign, true or false. Lets add new class:

class Entity {
  final String wordpair;
  final bool isFavorite;
  final DocumentReference reference;

  Entity.fromMap(Map<String, dynamic> map, {this.reference})
      : assert(map['word'] != null),
        assert(map['isFavorite'] != null),
        wordpair = map['word'],
        isFavorite = map['isFavorite'];

  Entity.fromSnapshot(DocumentSnapshot snapshot)
      : this.fromMap(snapshot.data, reference: snapshot.reference);

  @override
  String toString() => "WordPair<$wordpair:$isFavorite>";
}