Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad lint raised "Use 'const' with the constructor to improve performance" #4807

Open
sbatezat opened this issue Nov 24, 2023 · 0 comments
Open
Labels
false-positive P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sbatezat
Copy link

sbatezat commented Nov 24, 2023

I'v just upgraded flutter to 3.10.6 & flutter_lints to 3.0.1
I've got a lint issue on my Widget "Use 'const' with the constructor to improve performance".
But it's not a const! If I accept to change it to a const, lint issue disappear but I'm unable to build the application :

Error: Not a constant expression.
my_file.dart:154
borderRadius: BorderRadius.all(_cardBorderRadius),

The code where there is an issue :

class MyWidget extends StatelessWidget {
  // A final global variable... yes, it's not a const it's final...
  final _cardBorderRadius = const Radius.circular(12);
  
  BorderRadius _buildBorderRadius() {
    // Here is the lint issue: lint should not ask for a const keyword before the border radius declaration
    return BorderRadius.all(_cardBorderRadius);
  }
}
@bwilkerson bwilkerson added false-positive P2 A bug or feature request we're likely to work on labels Nov 28, 2023
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants