Remove NavigationToolbar condition that leading widget cannot be larger than 1/3 the total space available.#112548
Conversation
…er than 1/3 the total space available.
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Added a test |
|
@LongCatIsLooong may be the right person to review. The original reason this was added was to match iOS's default behavior, especially around back button labels when the text gets long. If that behavior still matches, we should remove this (especially since this affects Material too) |
|
Also tagging @justinmc |
| @@ -106,7 +106,7 @@ class _ToolbarLayout extends MultiChildLayoutDelegate { | |||
|
|
|||
| if (hasChild(_ToolbarSlot.leading)) { | |||
| final BoxConstraints constraints = BoxConstraints( | |||
There was a problem hiding this comment.
More of a question, should this just be BoxConstraints.loose(size) to match the trailing widget? @xster
There was a problem hiding this comment.
I think it likely can be (if all the tests still pass)
justinmc
left a comment
There was a problem hiding this comment.
LGTM 👍 but please try BoxConstraints.loose as mentioned in https://github.com/flutter/flutter/pull/112548/files#r987147503.
|
BoxConstraints.loose() fails tests: |
|
You might need to center the leading widget vertically (similar to how the trailing widget is positioned: |
|
I feel like loosening the constraints is a much riskier change than what I set out to do, and I'd rather keep this change small and safe. |
|
Ok I'll try that after this is merged. |
… be larger than 1/3 the total space available. (flutter/flutter#112548)
… be larger than 1/3 the total space available. (flutter/flutter#112548)
|
Hello, everyone! I know this PR is considerably old, but we recently upgraded from Flutter 3.3 to Flutter 3.10 and some things broke in our app, I think it's related with this change. Is this a breaking change? If so, it was not documented in the breaking changes page. In our case, we relied on the constraint to use a |
|
Exemplifying what @mateusfccp just said: Notice how the title widget just disappears and there is no overflow warning showing. The code for the examples above: AppBar(
leadingWidth: 500,
title: Text(widget.title),
leading: Row(
children: [BackButton(), Text('A widget')],
),
actions: const [Text('Another widget')],
)Btw, If I remove the leadingWidth, in both cases the title becomes visible and the leading overlaps the title, and shows an overflow warning. |
|
This change isn't considered breaking per the definition here: https://github.com/flutter/flutter/wiki/Tree-hygiene#1-determine-if-your-change-is-a-breaking-change. You can register your tests in For this specific problem I think you can always use a |
Yeah, you may be right strictly speaking. Should we reconsider this definition? I mean, our app simply broke in terms of layout, but we didn't notice at the time of migration, just later. Maybe we could say that it's our fault for not testing it thoroughly, but considering this kind of change affects potentially thousands of consumers and is a silent breakage (different, for instance, from an API breakage that will break as soon as possible instead of in runtime), maybe we should review what are our definitions of a breaking change. I know this is not the purpose of this PR, but I am trying to collect early feedback. Do you think this is a valid discussion that we should open as an issue? |
When directly using The only options we have is:
Maybe there's another solution we didn't consider? |
|
Your second bullet is exactly what I would suggest. What is your concern with it? |
|
Ah I meant using a The current option is to register your tests in the |
Not a big concern, but overall I don't think it's a good practice to wrap a build around a big widget tree when only a small portion of it needs it. |
The issue is that I have to pass a preferred size to In this sense, wrapping |
It's part of |
I am not sure, as I need final appBar = LayoutBuilder(
(context, constraints) => AppBar(leadingWidth: constraints.maxWidth / 3.0, ...),
); // appBar is `LayoutBuilder`, so can't be usedIf I assign |


Remove a constraint in NavigationToolbar that the leading widget cannot be larger than 1/3 the total space available. There's no good reason for this constraint, and there are situations where somebody may want to have a larger leading widget.
For example, in my app, on large screens we want to restrict the content area to a maximum 960dp width. The way we are doing that is by padding the leading and trailing elements with any excess width. However, this means that on screens larger than 2880dp wide, the leading element cannot actually take up as much space as we want. This leads to rendering bugs like this:
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.