numen31337 / copy_with_extension

Provides Dart Build System builder for generating copyWith extensions for annotated classes.
https://pub.dev/packages/copy_with_extension_gen
MIT License
74 stars 30 forks source link

Warning: Operand of null-aware operation '!' has type 'List<int>' which excludes null. #75

Closed thetoster closed 1 year ago

thetoster commented 1 year ago

After generation of .g.dart for following classes:


@CopyWith()
class MyList {
  final List<int> integers;
  final List<String> strings;
  final List<MyTypeInList> customType;
  final List<dynamic> dynamicType;
  final List<dynamic> expDynamicType;

  MyList({
    required this.integers,
    required this.strings,
    required this.customType,
    required this.dynamicType,
    required this.expDynamicType,
  });
}

@CopyWith()
class MyTypeInList {
  final int val;

  MyTypeInList({
    required this.val,
  });
}

@CopyWith()
class MyOtherInList {
  final String str;

  MyOtherInList({
    required this.str,
  });
}

I got several warnings in console while compiling project:

lib/src/model/list_test.g.dart:77:20: Warning: Operand of null-aware operation '!' has type 'List<int>' which excludes null.
 - 'List' is from 'dart:core'.
          ? _value.integers!
                   ^
lib/src/model/list_test.g.dart:82:20: Warning: Operand of null-aware operation '!' has type 'List<String>' which excludes null.
 - 'List' is from 'dart:core'.
          ? _value.strings!
                   ^
lib/src/model/list_test.g.dart:88:24: Warning: Operand of null-aware operation '!' has type 'List<MyTypeInList>' which excludes null.
 - 'List' is from 'dart:core'.
 - 'MyTypeInList' is from 'package:example/src/model/list_test.dart' ('lib/src/model/list_test.dart').
              ? _value.customType!
                       ^
lib/src/model/list_test.g.dart:94:24: Warning: Operand of null-aware operation '!' has type 'List<dynamic>' which excludes null.
 - 'List' is from 'dart:core'.
              ? _value.dynamicType!
                       ^
lib/src/model/list_test.g.dart:100:20: Warning: Operand of null-aware operation '!' has type 'List<dynamic>' which excludes null.
 - 'List' is from 'dart:core'.
          ? _value.expDynamicType!
                   ^
lib/src/model/list_test.g.dart:150:20: Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
          ? _value.val!
                   ^
lib/src/model/list_test.g.dart:200:20: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
          ? _value.str!
                   ^

Package version

dependencies:
  copy_with_extension: ^5.0.0
dev_dependencies:
  copy_with_extension_gen: ^5.0.0

Expected behavior: No warnings in auto generated code.