Skip to content

Commit 6fcecff

Browse files
authored
refactor: improve Equatable stringify handling and clean up props usage (#722)
* refactor: add factory constructor and update docs for EquatablePropToString * fix: use raw fields in props instead of EquatablePropToString wrapper * feat: enable Equatable.stringify based on local or remote log level * chore: remove unused utils import from bloc files * chore: update Equatable props to use nullable object list
1 parent fe6954d commit 6fcecff

49 files changed

Lines changed: 232 additions & 449 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/app/notifications/bloc/notifications_bloc.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import 'package:equatable/equatable.dart';
33
import 'package:bloc_concurrency/bloc_concurrency.dart';
44
import 'package:freezed_annotation/freezed_annotation.dart';
55

6-
import 'package:webtrit_phone/utils/utils.dart';
7-
8-
import '../models/models.dart';
6+
import 'package:webtrit_phone/app/notifications/notifications.dart';
97

108
part 'notifications_bloc.freezed.dart';
119

lib/app/notifications/bloc/notifications_event.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sealed class NotificationsEvent extends Equatable {
44
const NotificationsEvent();
55

66
@override
7-
List<Object> get props => [];
7+
List<Object?> get props => [];
88
}
99

1010
class NotificationsSubmitted extends NotificationsEvent {
@@ -13,9 +13,7 @@ class NotificationsSubmitted extends NotificationsEvent {
1313
final Notification notification;
1414

1515
@override
16-
List<Object> get props => [
17-
EquatablePropToString([notification], listPropToString),
18-
];
16+
List<Object?> get props => [notification];
1917
}
2018

2119
class NotificationsCleared extends NotificationsEvent {

lib/blocs/app/app_event.dart

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sealed class AppEvent extends Equatable {
44
const AppEvent();
55

66
@override
7-
List<Object> get props => [];
7+
List<Object?> get props => [];
88
}
99

1010
class _SessionUpdated extends AppEvent {
@@ -13,9 +13,7 @@ class _SessionUpdated extends AppEvent {
1313
final Session? session;
1414

1515
@override
16-
List<Object> get props => [
17-
EquatablePropToString([session], listPropToString),
18-
];
16+
List<Object?> get props => [session];
1917
}
2018

2119
class AppThemeSettingsChanged extends AppEvent {
@@ -24,9 +22,7 @@ class AppThemeSettingsChanged extends AppEvent {
2422
final ThemeSettings value;
2523

2624
@override
27-
List<Object> get props => [
28-
EquatablePropToString([value], listPropToString),
29-
];
25+
List<Object?> get props => [value];
3026
}
3127

3228
class AppThemeModeChanged extends AppEvent {
@@ -35,9 +31,7 @@ class AppThemeModeChanged extends AppEvent {
3531
final ThemeMode value;
3632

3733
@override
38-
List<Object> get props => [
39-
EquatablePropToString([value], listPropToString),
40-
];
34+
List<Object?> get props => [value];
4135
}
4236

4337
class AppLocaleChanged extends AppEvent {
@@ -46,9 +40,7 @@ class AppLocaleChanged extends AppEvent {
4640
final Locale value;
4741

4842
@override
49-
List<Object> get props => [
50-
EquatablePropToString([value], listPropToString),
51-
];
43+
List<Object?> get props => [value];
5244
}
5345

5446
sealed class AppAgreementAccepted extends AppEvent {
@@ -65,9 +57,7 @@ class _UserAppAgreementUpdate extends AppAgreementAccepted {
6557
final AgreementStatus status;
6658

6759
@override
68-
List<Object> get props => [
69-
EquatablePropToString([status], listPropToString),
70-
];
60+
List<Object?> get props => [status];
7161
}
7262

7363
class _ContactsAppAgreementUpdate extends AppAgreementAccepted {
@@ -76,7 +66,5 @@ class _ContactsAppAgreementUpdate extends AppAgreementAccepted {
7666
final AgreementStatus status;
7767

7868
@override
79-
List<Object> get props => [
80-
EquatablePropToString([status], listPropToString),
81-
];
69+
List<Object?> get props => [status];
8270
}

lib/blocs/external_contacts_sync/external_contacts_sync_event.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sealed class ExternalContactsSyncEvent extends Equatable {
44
const ExternalContactsSyncEvent();
55

66
@override
7-
List<Object> get props => [];
7+
List<Object?> get props => [];
88
}
99

1010
class ExternalContactsSyncStarted extends ExternalContactsSyncEvent {
@@ -18,12 +18,8 @@ class ExternalContactsSyncRefreshed extends ExternalContactsSyncEvent {
1818
class _ExternalContactsSyncUpdated extends ExternalContactsSyncEvent {
1919
final List<ExternalContact> contacts;
2020

21-
const _ExternalContactsSyncUpdated({
22-
required this.contacts,
23-
});
21+
const _ExternalContactsSyncUpdated({required this.contacts});
2422

2523
@override
26-
List<Object> get props => [
27-
EquatablePropToString(contacts, listPropToString),
28-
];
24+
List<Object?> get props => [EquatablePropToString.list(contacts)];
2925
}

lib/blocs/external_contacts_sync/external_contacts_sync_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ abstract class ExternalContactsSyncState extends Equatable {
55
const ExternalContactsSyncState();
66

77
@override
8-
List<Object> get props => [];
8+
List<Object?> get props => [];
99
}
1010

1111
class ExternalContactsSyncInitial extends ExternalContactsSyncState {

lib/blocs/local_contacts_sync/local_contacts_sync_event.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sealed class LocalContactsSyncEvent extends Equatable {
44
const LocalContactsSyncEvent();
55

66
@override
7-
List<Object> get props => [];
7+
List<Object?> get props => [];
88
}
99

1010
class LocalContactsSyncStarted extends LocalContactsSyncEvent {
@@ -18,12 +18,8 @@ class LocalContactsSyncRefreshed extends LocalContactsSyncEvent {
1818
class _LocalContactsSyncUpdated extends LocalContactsSyncEvent {
1919
final List<LocalContact> contacts;
2020

21-
const _LocalContactsSyncUpdated({
22-
required this.contacts,
23-
});
21+
const _LocalContactsSyncUpdated({required this.contacts});
2422

2523
@override
26-
List<Object> get props => [
27-
EquatablePropToString(contacts, listPropToString),
28-
];
24+
List<Object?> get props => [EquatablePropToString.list(contacts)];
2925
}

lib/blocs/local_contacts_sync/local_contacts_sync_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ abstract class LocalContactsSyncState extends Equatable {
55
const LocalContactsSyncState();
66

77
@override
8-
List<Object> get props => [];
8+
List<Object?> get props => [];
99
}
1010

1111
class LocalContactsSyncInitial extends LocalContactsSyncState {

lib/data/app_logger.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:equatable/equatable.dart';
12
import 'package:logging/logging.dart';
23
import 'package:logging_appenders/logging_appenders.dart';
34

@@ -21,6 +22,8 @@ class AppLogger {
2122
Logger.root.clearListeners();
2223
Logger.root.level = localLogLevel;
2324

25+
EquatableConfig.stringify = localLogLevel <= Level.FINE || logzioLogLevel <= Level.FINE;
26+
2427
// Set up local logs printing with a color formatter
2528
PrintAppender(formatter: const ColorFormatter()).attachToLogger(Logger.root);
2629

lib/data/app_themes.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,5 @@ class AppTheme extends Equatable {
111111
final ThemeSettings settings;
112112

113113
@override
114-
List<Object> get props => [
115-
settings,
116-
];
114+
List<Object?> get props => [settings];
117115
}

0 commit comments

Comments
 (0)