Created
February 8, 2020 13:31
-
-
Save onikazu/0a17acd65b073021281c3a1a19b28de2 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
class Record { | |
final String name; | |
final int votes; | |
final DocumentReference reference; | |
// for null safety | |
// Initializer Lists constructor | |
// option arguments | |
// https://makicamel.hatenablog.com/entry/2019/03/14/213933 | |
Record.fromMap(Map<String, dynamic> map, {this.reference}) | |
: assert(map["name"] != null), | |
assert(map["votes"] != null), | |
name = map["name"], | |
votes = map["votes"]; | |
// Initializer Lists constructor | |
Record.fromSnapshot(DocumentSnapshot snapshot) | |
: this.fromMap(snapshot.data, reference: snapshot.reference); | |
@override | |
String toString() => "Record<$name: $votes>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment