You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the issue
Unnecessary nullable on dynamic fields.
If I have a filed like dynamic data the generated code will use dynamic? data in the _$MyClassCWProxy implementation.
Another issue with dynamic fields I just faced is this:
MyClasscall({
dynamic? data,
});
MyClasscall({
Object? data =const$CopyWithPlaceholder(),
}) {
returnMyClass(
data: data ==const$CopyWithPlaceholder() || data ==null// ignore: unnecessary_non_null_assertion? _value.data!// ignore: cast_nullable_to_non_nullable: data asdynamic,
);
}
Specifically the _value.data! and the previous condition data == null, so when data is null and I use: var copyInstance = instance.copyWith(); NullPointerException throws.
I think generated code should look like:
MyClasscall({
dynamic data,
});
MyClasscall({
Object? data =const$CopyWithPlaceholder(),
}) {
returnMyClass(
data: data ==const$CopyWithPlaceholder()
// ignore: unnecessary_non_null_assertion? _value.data
// ignore: cast_nullable_to_non_nullable: data asdynamic,
);
}
TestNullabilitycall({
int? nullableWithNonNullableConstructor,
dynamic? dynamicField, /// <--- ISSUE, dynamic? makes no sense.List<int>? integers,
});
// info • test/gen_nullability_test.g.dart:25:12 • The '?' is unnecessary because 'dynamic' is nullable without it. • unnecessary_question_mark
Describe the issue
Unnecessary nullable on dynamic fields.
If I have a filed like
dynamic data
the generated code will usedynamic? data
in the_$MyClassCWProxy
implementation.Paste the package version.
To Reproduce
Steps to reproduce the behaviour:
Expected behaviour
Avoid using unnecessary ? on dynamic fields.
The text was updated successfully, but these errors were encountered: