prefer_declaring_const_constructors lint showing for the constructors with a super initializer that is not a const
imsamgarg opened this issue · comments
Is there an existing issue for this bug?
- I have searched the existing issues.
Bug Description
prefer_declaring_const_constructors lint showing for the constructors with a super initializer that is not a const.
Steps to Reproduce
Just create any constructor in any class that has a super initializer that is not const.
Additional Information
No response
That's because the constructor of Temp
is not a const constructor.
There are a few edge cases that I didn't consider when I implemented the lint. I will spend some time improving it.
Thanks for raising the issue!
The lint should not be triggered when the redirecting/super constructor is not a const constructor.
class Point {
final double x;
final double y;
Point(this.x, this.y);
Point.origin() : this(0, 0); // Redirecting constructor is not const
}
class Point3D extends Point {
final double z;
Point3D(double x, double y, this.z) : super(x, y); // Super constructor is not const
// Point3D(super.x, super.y, this.z); // Need to handle super parameters as well
Point3D.origin() // Super constructor is not const
: z = 0,
super.origin();
}
Fixed false positive when redirecting/super constructor is not a const constructor in #29.
Still need to come up with a way to check for super parameters.
Hello!
Is NativeFileType.fromPath
a factory constructor?
Could you provide a minimum reproducible example for me to work on?
For some reason, it's not showing anymore even though I didn't change anything.