Skip to content

Commit

Permalink
One-level deep List equality check using package:collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldemarco committed Jan 23, 2019
1 parent fbf8891 commit fadaea0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions auto_data_generator/lib/src/file_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ class FileGenerator {
buffer.writeln('other is ${c.name} &&');
buffer.writeln('runtimeType == other.runtimeType &&');

final params =
c.props.map((p) => '${p.name} == other.${p.name}').join(' && ');
final params = c.props.map((p) {
if (p.type.startsWith('List')) {
return 'const ListEquality().equals(${p.name}, other.${p.name})';
} else {
return '${p.name} == other.${p.name}';
}
}).join(' && ');
buffer.write(params);

buffer.writeln(';');
Expand Down

0 comments on commit fadaea0

Please sign in to comment.