Replace all BorderRadius.circular with const BorderRadius.all#91239
Conversation
|
Isn't there a way to make |
Nope, we have to create |
Piinks
left a comment
There was a problem hiding this comment.
Wow this is awesome thank you. LGTM
It makes me wonder if we should deprecate BorderRadius.circular and refer folks to the const option here.
Also might be a good prefer type lint, @a14n do you think that would be a good candidate? I think deprecating it might be better.
|
The reason we have the Thanks @grafovdenis! |
Sure! People would be free to enable this lint if they like verbosity :). Feel free to file an issue on linter package! |
|
@Piinks @Hixie @a14n |
I'm generally curious, do you have a limitation on using community packages? Coz we provide an analyzer plugin with this rule already implemented, but you want to implement the same rule in the |
|
For instance, if the motivation is not to depend on any community package (coz they can be abandoned, contain malicious code, etc.), then it's totally understandable. |
|
It's more about minimizing the number of dependencies for the core packages. There's a number of complicated implications about using packages from the core framework, for example we have to pin everything which means that anybody using the framework has to use the exact version of the dependency that the framework uses (even if there's a newer version), there's the impact on the license file size (which is already ~1MB!), and so on. You are more than welcome to submit PRs to the linter package though. Many of the lints in the (It's not just about who wrote the package, either, for example we currently depend on vector_math, which was made by the Dart team, but we're seriously considering inlining the relevant code into the Flutter framework to avoid having that dependency. We literally have a test that checks that nobody is adding more dependencies and flags them when they get added.) |
|
Thank you for the answer! Honestly, I was not expecting that you pin every package version and have a test for dependencies, but now it explains a lot. |
|
Yeah, we started doing that because otherwise any dependency that made a slight change that stopped the tool from compiling would mean that all our users would get stuck on a broken version and the tool would be unable to run to get them fixed. (And also any dependency that made an analyzer error pop up or anything like that on any of our tests anywhere would cause our CI to go red, which was happening at least once a week before we pinned everything.) |
I can see that I think having |
This PR contains such replacements:
BorderRadius.circular(arg)->const BorderRadius.all(Radius.circular(arg)).I ran new Dart Code Metrics rule prefer-const-border-radius on flutter repo and left
test/painting/border_radius_test.dartunchanged since it testsBorderRadius.circularbehaviour.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.