Skip to content

Commit

Permalink
Add equality operator to AnalyticsEvent (#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsreichardt authored Jun 21, 2024
1 parent 2105446 commit b1dbc81
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/analytics/lib/src/analytics/analytics.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:collection/collection.dart';

// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt)
// Licensed under the EUPL-1.2-or-later.
//
Expand All @@ -16,6 +18,19 @@ class AnalyticsEvent {
String toString() {
return "$runtimeType(name:$name, data: $data)";
}

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
final mapEquals = const DeepCollectionEquality().equals;

return other is AnalyticsEvent &&
other.name == name &&
mapEquals(other.data, data);
}

@override
int get hashCode => name.hashCode ^ data.hashCode;
}

// ignore: one_member_abstracts
Expand Down
2 changes: 1 addition & 1 deletion lib/analytics/pubspec.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ environment:
dependencies:
flutter:
sdk: flutter
collection: ^1.17.2
crash_analytics:
path: ../crash_analytics
firebase_analytics: ^10.10.4
Expand Down

0 comments on commit b1dbc81

Please sign in to comment.