Open khoadng opened 2 years ago
Another false positive in this case also.
prefer_const_literals_to_create_immutables
@immutable
class Foo<T> {
const Foo({
required this.list,
});
// ignore: prefer_const_constructors
factory Foo.bar() => Foo(
list: <T>[], // prefer_const_literals_to_create_immutables
);
Foo<T> copyWith({
List<T>? list,
}) =>
Foo(list: list ?? this.list);
final List<T> list;
}
This is a duplicate (or near enough) of https://github.com/dart-lang/linter/issues/1629
Describe the issue When initialize an object with default value using factory constructor, warning will be showed. However if I add the
const
keyword, the code will fail to compile. Remove the type will result in runtime error.To Reproduce
Expected behavior No warning
Additional context If I left out the type and apply the suggestion, the warning will disappear but it will result in error in the below case