Skip to content

Instantly share code, notes, and snippets.

/// 0 - Example `Streams`
Stream<MyUserModel> userStream => FirebaseAuth
.instance
.onAuthStateChanged
.map((user) => MyUserModel.fromFirebase(user));
String documentPath = 'my/document';
Stream<MyDocumentModel> documentStream = Firestore.instance
.document(documentPath)
.snapshots()
@oodavid
oodavid / main.dart
Created January 22, 2020 17:17
Dart > Sort List<Map> by multiple keys
extension SortBy on List {
sortBy(List<String> keys) {
this.sort((a, b) {
for(int k=0; k<keys.length; k++) {
String key = keys[k];
int comparison = Comparable.compare((a[key]??""), (b[key]??""));
if(comparison != 0){
return comparison;
}
}