Skip to content

Conversation

@lewinpauli
Copy link
Contributor

@lewinpauli lewinpauli commented Jun 26, 2025

Implements computeDryBaseline method in RenderAligningShiftedBox to fix layout failures when DropdownButtonFormField is used inside Wrap inside AlertDialog. The method calculates baseline using dry layout methods and accounts for child positioning within the parent's coordinate space.

Issue appeared when DropdownButtonFormField was used inside a Wrap inside Alertdialog

Fixes flutter/flutter/issues/169214

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Implements computeDryBaseline method in RenderShiftedBox to fix layout
failures when DropdownButtonFormField is used inside Wrap inside AlertDialog.
The method calculates baseline using dry layout methods and accounts for
child positioning within the parent's coordinate space.

Fixes flutter/issues/169214
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

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.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla
Copy link

google-cla bot commented Jun 26, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 26, 2025
@justinmc
Copy link
Contributor

justinmc commented Jul 8, 2025

Thanks for opening a PR for this! Would you be able to add a test? Ideally something that reproduces the issue in #169214 and shows that it no longer happens with this change.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@lewinpauli
Copy link
Contributor Author

@justinmc while creating tests i came across that "RenderSizedBox" has not implemented method "computeDryBaseline" either, but i don't have a deep flutter framework understanding so i don't know if this is a bug

test('computeDryBaseline returns null when child has no baseline', () {
      final RenderSizedBox child = RenderSizedBox(const Size(50.0, 50.0));
      final RenderPadding padding = RenderPadding(
        padding: const EdgeInsets.all(10.0),
        child: child,
      );

      final double? baseline = padding.computeDryBaseline(
        const BoxConstraints(maxWidth: 100.0, maxHeight: 100.0),
        TextBaseline.alphabetic,
      );

      expect(baseline, isNull);
    });
The RenderSizedBox class does not implement "computeDryBaseline".
If you are not writing your own RenderBox subclass, then this is not
your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=02_bug.yml
package:flutter/src/rendering/box.dart 2229:9          RenderBox.debugCannotComputeDryLayout.<fn>
package:flutter/src/rendering/box.dart 2233:6          RenderBox.debugCannotComputeDryLayout
package:flutter/src/rendering/box.dart 2184:7          RenderBox.computeDryBaseline
package:flutter/src/rendering/box.dart 2140:50         RenderBox._computeDryBaseline
package:flutter/src/rendering/box.dart 1088:42         _Baseline.memoize.ifAbsent
dart:_compact_hash                                     _LinkedHashMapMixin.putIfAbsent
package:flutter/src/rendering/box.dart 1089:18         _Baseline.memoize
package:flutter/src/rendering/box.dart 1620:32         RenderBox._computeWithTimeline
package:flutter/src/rendering/box.dart 1598:26         RenderBox._computeIntrinsics
package:flutter/src/rendering/box.dart 2118:36         RenderBox.getDryBaseline
package:flutter/src/rendering/shifted_box.dart 255:30  RenderPadding.computeDryBaseline
test/rendering/shifted_box_test.dart 52:40             main.<fn>.<fn>
shifted_box_test.dart:52
✖ RenderShiftedBox computeDryBaseline returns null when child has no baseline

@github-actions github-actions bot added the a: desktop Running on desktop label Jul 29, 2025
@lewinpauli
Copy link
Contributor Author

lewinpauli commented Jul 30, 2025

@justinmc how can i add a checksum in my pubspec.yaml, that is needed for my integration test. Which algorithm/command is used?

(most of the tests in CI/CD are failing because the checksum does not exist)

locally integration test reproduces the flutter error flutter/flutter/issues/169214 and ensures its working

name: alert_dialog_dropdown_crash
description: An integration test to reproduce AlertDialog with DropdownButton crash.
environment:
  sdk: ^3.8.0-0

# resolution: workspace

dependencies:
  flutter:
    sdk: flutter
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter
  test: any

  meta: any

flutter:
  uses-material-design: true

# PUBSPEC CHECKSUM: ?????

@lewinpauli lewinpauli changed the title Added computeDryBaseline implementation in RenderShiftedBox Added computeDryBaseline implementation in RenderAligningShiftedBox Jul 30, 2025
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you don't need an integration test at all?

I'm still curious about the checksum though. I actually don't know how those are generated off the top of my head. I'll look for an answer either way.

Edit: I believe you need to run flutter update-packages --update-hashes to update that checksum. Thanks to @jason-simmons for helping me out with that.

lewinpauli and others added 4 commits August 2, 2025 10:20
…st/material/dropdown_dialog_baseline_test.dart and update computeDryBaseline in RenderAligningShiftedBox to prevent crashes with DropdownButton in AlertDialog
@github-actions github-actions bot added f: material design flutter/packages/flutter/material repository. and removed a: desktop Running on desktop labels Aug 10, 2025
@lewinpauli
Copy link
Contributor Author

lewinpauli commented Aug 10, 2025

@justinmc I added missing computeDryBaseline in RenderAlignedShiftedBox

also now a unittest exists: packages/flutter/test/rendering/shifted_box_test.dart

and I replaced the integration test with a much less ressource intensive widget test: packages/flutter/test/rendering/aligning_shifted_box_baseline_test.dart

to verify computeDryBaseline in RenderAlignedShiftedBox exists, and the widget test reproduces the issue in #169214

@chunhtai chunhtai self-requested a review August 20, 2025 21:49
…eline

Resolved merge conflicts in packages/flutter/lib/src/semantics/binding.dart

Removed semantics_binding_set_semantics_tree_enabled_test.dart (deleted upstream)
@github-actions github-actions bot removed the a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) label Aug 25, 2025
@lewinpauli
Copy link
Contributor Author

lewinpauli commented Aug 27, 2025

To provide some context, I originally wanted to fix an issue that appeared when a DropdownButtonFormField was used inside a Wrap inside an AlertDialog, as described in #169214. The issue was that the implementation of the 'computeDryBaseline' function was missing in the 'RenderAligningShiftedBox' class. I added this, as well as unit and widget tests.

Quite a few tests were failing, so I had to edit some files. For example, the renderAnimatedSize also had no computeDryBaseline implementation, as did RenderShiftedBox, RenderPositionedBox and _RenderBadge.

In material/button.dart, material/button_style_button.dart and _RenderInputPadding, the Size(width, height) was mixed up.

@dkwingsmt dkwingsmt requested a review from justinmc September 17, 2025 18:29
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as long as Google tests pass. Thank you for all of the work and iterations on this. The lack of (or incorrect) dry layout calculations were probably causing headaches for a lot of users.

Comment on lines -511 to +513
final double height = math.max(childSize.width, minSize.width);
final double width = math.max(childSize.height, minSize.height);
return constraints.constrain(Size(height, width));
final double width = math.max(childSize.width, minSize.width);
final double height = math.max(childSize.height, minSize.height);
return constraints.constrain(Size(width, height));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

if (result == null) {
return null;
}
// Calculate the size and child offset using the same logic as performLayout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Period at the end of this comment and a few other comments below.

Comment on lines +1058 to +1063
double pos = leadingSpace;
for (RenderBox? child = startChild; child != null; child = nextChildPaintOrder(child)) {
mainPositions[child] = pos;
final BoxConstraints cc = constraintsForChild(child);
final Size cs = child.getDryLayout(cc);
pos += _getMainSize(cs) + betweenSpace;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid abbreviations per the styleguide, here and at least one more time below.

TextBaseline.alphabetic,
);

expect(baseline, isNotNull);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What caused you to expect isNotNull here instead of the specific value?

@dkwingsmt
Copy link
Contributor

Friendly ping @chunhtai Are you still comfortable reviewing this PR or would you like someone else to take over it? (from triage)

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once justin's comments are addressed

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 29, 2025

autosubmit label was removed for flutter/flutter/171250, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@dkwingsmt dkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 29, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 30, 2025
Merged via the queue into flutter:master with commit 1ac41be Oct 30, 2025
78 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 30, 2025
walley892 pushed a commit to walley892/flutter that referenced this pull request Oct 30, 2025
…lutter#171250)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

Implements computeDryBaseline method in RenderAligningShiftedBox to fix
layout failures when DropdownButtonFormField is used inside Wrap inside
AlertDialog. The method calculates baseline using dry layout methods and
accounts for child positioning within the parent's coordinate space.

Issue appeared when DropdownButtonFormField was used inside a Wrap
inside Alertdialog

Fixes
[flutter/issues/169214](flutter#169214)


## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <[email protected]>
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 30, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 30, 2025
flutter/flutter@df72035...6f8abdd

2025-10-30 [email protected] Roll Skia from 5035cdc7de31 to 18457971c30f (1 revision) (flutter/flutter#177767)
2025-10-30 [email protected] Roll Skia from 018e2cdba2fe to 5035cdc7de31 (3 revisions) (flutter/flutter#177764)
2025-10-30 [email protected] Roll Dart SDK from a0480f399f8f to 4785d5971d64 (21 revisions) (flutter/flutter#177760)
2025-10-30 [email protected] Roll Skia from c803f12d2e26 to 018e2cdba2fe (1 revision) (flutter/flutter#177759)
2025-10-30 [email protected] Roll Skia from 51267d4a2cea to c803f12d2e26 (2 revisions) (flutter/flutter#177756)
2025-10-30 [email protected] Roll Fuchsia Linux SDK from 3EF6k6lqXPWDwrdyj... to ksXeDDo2yYBXJ4uEu... (flutter/flutter#177754)
2025-10-30 [email protected] impeller: allow setting image sampler uniforms by name (flutter/flutter#176749)
2025-10-30 [email protected] Roll Skia from 0a0c9f8c704f to 51267d4a2cea (21 revisions) (flutter/flutter#177752)
2025-10-30 [email protected] Copy symlinks when creating android cipd package, and update to package w/ symlinks (flutter/flutter#177638)
2025-10-30 [email protected] [web] Add GEMINI.md for web engine customizations (flutter/flutter#177413)
2025-10-30 [email protected] Added computeDryBaseline implementation in RenderAligningShiftedBox (flutter/flutter#171250)
2025-10-29 [email protected] Refactor OverlayPortal semantics (flutter/flutter#173005)
2025-10-29 [email protected] [web] Delete unused canvaskit utils (flutter/flutter#177684)
2025-10-29 [email protected] Fixed image links in //README.md (flutter/flutter#177750)
2025-10-29 [email protected] Disable LTO in CI builder configurations for Linux targets (flutter/flutter#177694)
2025-10-29 [email protected] [web] Move webparagraph tests to their right location (flutter/flutter#177739)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…lutter#171250)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

Implements computeDryBaseline method in RenderAligningShiftedBox to fix
layout failures when DropdownButtonFormField is used inside Wrap inside
AlertDialog. The method calculates baseline using dry layout methods and
accounts for child positioning within the parent's coordinate space.

Issue appeared when DropdownButtonFormField was used inside a Wrap
inside Alertdialog

Fixes
[flutter/issues/169214](flutter#169214)


## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenderPositionedBox class does not implement "computeDryBaseline" Alertdialog -> Wrap -> SizedBox -> DropdownButtonFormField

4 participants