Skip to content

Commit

Permalink
refactor: simplify toString logic (#140)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Angelov <felangelov@gmail.com>
  • Loading branch information
Amir-P and felangel committed Oct 14, 2023
1 parent 183182d commit 49e92fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions lib/src/equatable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,9 @@ abstract class Equatable {

@override
String toString() {
switch (stringify) {
case true:
return mapPropsToString(runtimeType, props);
case false:
return '$runtimeType';
default:
return EquatableConfig.stringify == true
? mapPropsToString(runtimeType, props)
: '$runtimeType';
if (stringify ?? EquatableConfig.stringify) {
return mapPropsToString(runtimeType, props);
}
return '$runtimeType';
}
}
12 changes: 3 additions & 9 deletions lib/src/equatable_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,9 @@ mixin EquatableMixin {

@override
String toString() {
switch (stringify) {
case true:
return mapPropsToString(runtimeType, props);
case false:
return '$runtimeType';
default:
return EquatableConfig.stringify == true
? mapPropsToString(runtimeType, props)
: '$runtimeType';
if (stringify ?? EquatableConfig.stringify) {
return mapPropsToString(runtimeType, props);
}
return '$runtimeType';
}
}

0 comments on commit 49e92fa

Please sign in to comment.