Skip to content

[cloud_firestore] FieldValue should support equality comparison #2018

Closed
@collinjackson

Description

@collinjackson

Right now FieldValue.delete() returns values that don't equals(). We should fix this to make unit testing mocks easier. The change should look something like this:

diff --git a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/method_channel_field_value.dart b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/method_channel_field_value.dart
index 0a598dfb..ed9d2b51 100644
--- a/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/method_channel_field_value.dart
+++ b/packages/cloud_firestore/cloud_firestore_platform_interface/lib/src/method_channel/method_channel_field_value.dart
@@ -32,4 +32,13 @@ class MethodChannelFieldValue extends FieldValuePlatform {
 
   /// The value associated with the FieldValueType above.
   final dynamic value;
+
+  @override
+  bool operator ==(dynamic other) =>
+      other is MethodChannelFieldValue &&
+      other.type == type &&
+      other.value == value;
+
+  @override
+  int get hashCode => hashList(type, value);
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: criticalUsually a production crash with high user impact. (P1)type: enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions