Skip to content

Commit

Permalink
eliminates Warning: Operand of null-aware operation (#76)
Browse files Browse the repository at this point in the history
* Update copy_with_generator.dart

* Update pubspec.yaml

* remove unnecessary ignore comment.

* removed unnecessary cast_nullable_to_non_nullable comment

* Update pubspec.yaml

* Update copy_with_generator.dart

removed unnecessary ! cast

* Update pubspec.yaml

* Update copy_with_generator.dart

! for non nullable fields

* Update pubspec.yaml

* Update copy_with_generator.dart

* Update pubspec.yaml

* Update copy_with_generator.dart

* Update pubspec.yaml
  • Loading branch information
PROGrand authored Feb 26, 2023
1 parent b7ff813 commit 4142dc3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions copy_with_extension_gen/lib/src/copy_with_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,9 @@ class CopyWithGenerator extends GeneratorForAnnotation<CopyWith> {
final nullCheckForNonNullable =
v.nullable ? "" : "|| ${v.name} == null";

/// The `!` operator is needed to overcome a possible issue described here https://github.com/numen31337/copy_with_extension/pull/69#issue-1433703875
return '''$r ${v.isPositioned ? "" : '${v.name}:'}
${v.name} == const \$CopyWithPlaceholder() $nullCheckForNonNullable
${v.nullable ? '' : '// ignore: unnecessary_non_null_assertion'}
? _value.${v.name}${v.nullable ? '' : '!'}
// ignore: cast_nullable_to_non_nullable
: ${v.name} as ${v.type},''';
? _value.${v.name} : ${v.name} as ${v.type},''';
},
);

Expand Down
2 changes: 1 addition & 1 deletion copy_with_extension_gen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: copy_with_extension_gen
version: 5.0.0
version: 5.0.0+6
description: Automatically generating `copyWith` extensions code for classes with `@CopyWith()` annotation.
repository: https://github.com/numen31337/copy_with_extension
homepage: https://github.com/numen31337/copy_with_extension/tree/master/copy_with_extension_gen
Expand Down

0 comments on commit 4142dc3

Please sign in to comment.