Browse Source

Add equals and hashcode to Asset

Matthias Rupp 2 years ago
parent
commit
0deb8f4090
1 changed files with 9 additions and 0 deletions
  1. 9 0
      mobile/lib/shared/models/asset.dart

+ 9 - 0
mobile/lib/shared/models/asset.dart

@@ -50,6 +50,15 @@ class Asset {
     }
   }
 
+  @override
+  bool operator ==(other) {
+    if (other is! Asset) return false;
+    return id == other.id && isLocal == other.isLocal;
+  }
+
+  @override
+  int get hashCode => id.hashCode;
+
   Map<String, dynamic> toJson() {
     final json = <String, dynamic>{};
     if (isLocal) {