-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
use_decorated_box
seems to be wrong: Its fix is not equivalent and changes UI
#58683
Comments
/fyi @minhqdao |
You're right, the final decoration = BoxDecoration(border: Border.all(width: 2));
DecoratedBox(
decoration: decoration,
child: Padding(
padding: decoration.padding!,
child: const MyChild(),
),
) Nevertheless, this means that a |
@minhqdao Thanks for the reply.
Well, maybe deprecate this lint? I really did not expect an official lint with seemingly trivial fix will lead to such behavior |
Related: #58703 |
CC @goderbauer Is this still a sound lint rule? should we just make the quick-fix better? |
In its current form, the lint rule is not great and we've refrained from using it in the framework: IMO, the rule itself doesn't provide a ton of value and contains this subtile padding foot gun. So I'd be in favor of just deprecating it. If we really want to salvage it, we'd have to improve its documentation around the padding issue (and also update its quick-fix to take that into consideration). |
Hi thanks for the linter! I use linter a lot, and when the
use_decorated_box
suggests me to replaceContainer
withDecoratedBox
I did that. Later I realized it has bugs.A very simple reproducible sample is like:
With its auto-fixed DecoratedBox version:
Suppose originally the page is 100x100 pixel. Then, the
MyChildWidget
inContainer
version will be 99x99, while that inDecoratedBox
version will be 100x100 - no padding is automatically added to avoid the children to collide with the decoration! This caused some of my UI to have subtle bugs later on.By the way, we can confirm this when looking at source code of Container:
So, if Container.decoration exists, it will automatically extra pad itself.
The text was updated successfully, but these errors were encountered: