From f9b145809fefbf5accddfe43f6b57b60f0cda01b Mon Sep 17 00:00:00 2001
From: singerdmx <singerdmx@gmail.com>
Date: Mon, 21 Dec 2020 01:23:51 -0800
Subject: [PATCH] Add style equals

---
 lib/models/documents/style.dart | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/lib/models/documents/style.dart b/lib/models/documents/style.dart
index 67194755..72161620 100644
--- a/lib/models/documents/style.dart
+++ b/lib/models/documents/style.dart
@@ -1,4 +1,6 @@
+import 'package:collection/collection.dart';
 import 'package:flutter_quill/models/documents/attribute.dart';
+import 'package:quiver_hashcode/hashcode.dart';
 
 /* Collection of style attributes */
 class Style {
@@ -79,4 +81,23 @@ class Style {
     m[attribute.key] = attribute;
     return Style.attr(m);
   }
+
+  @override
+  bool operator ==(Object other) {
+    if (identical(this, other)) return true;
+    if (other is! Style) return false;
+    Style typedOther = other;
+    final eq = const MapEquality<String, Attribute>();
+    return eq.equals(_attributes, typedOther._attributes);
+  }
+
+  @override
+  int get hashCode {
+    final hashes =
+        _attributes.entries.map((entry) => hash2(entry.key, entry.value));
+    return hashObjects(hashes);
+  }
+
+  @override
+  String toString() => "{${_attributes.values.join(', ')}}";
 }