Skip to content

fix: keep bottom sheet SafeArea inside the display-feature sub-screen - #195621

Draft
AdityaxDeore wants to merge 1 commit into
flutter:masterfrom
AdityaxDeore:fix/195218-bottom-sheet-safe-area-subscreen
Draft

AdityaxDeore wants to merge 1 commit into
flutter:masterfrom
AdityaxDeore:fix/195218-bottom-sheet-safe-area-subscreen

Conversation

@AdityaxDeore

Copy link
Copy Markdown

showModalBottomSheet(useSafeArea: true) subtracted the safe area of the
opposite sub-screen from a sheet confined to one display-feature
sub-screen: on a 951pt-wide foldable with an 80pt right safe area, a sheet
on the left sub-screen came out 375.5pt wide instead of 455.5pt.

ModalBottomSheetRoute.buildPage wrapped DisplayFeatureSubScreen in the
SafeArea. SafeArea shrinks the constraints but keeps MediaQuery.size,
so the sub-screen padded in full-window coordinates inside a box that was
already narrower by the inset.

The SafeArea (and the MediaQuery.removePadding used when
useSafeArea is false) is now applied inside the DisplayFeatureSubScreen,
mirroring how showDialog applies its SafeArea inside the sub-screen.
There, MediaQueryData.removeDisplayFeatures already gives each sub-screen
only the padding of its own edges, so nothing belonging to another
sub-screen is subtracted. The useSafeArea: false behavior is unchanged:
removePadding still removes the top padding, now read from the
sub-screen's trimmed MediaQuery, which yields the same result with and
without display features.

Fixes #195218

Tests

New regression test in bottom_sheet_test.dart (the issue's repro, placed
in the existing display-features group): fails before this change with
width 375.5, passes after with width 455.5.

  • flutter test test/material/bottom_sheet_test.dart test/widgets/display_feature_sub_screen_test.dart: 87 passed, 0 failed.
  • flutter analyze on the changed files: no issues. dart format: clean.

Note: this issue is labelled triaged-design / team-design and was
routed to the design team for evaluation with no verdict in the thread yet;
opening as a draft so the design team can weigh in. Also a draft because
the contributor already has 2 open PRs in this repo.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the AI contribution guidelines and understand my responsibilities, or I am not using AI tools.
  • 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. (The contributor will sign the Google CLA; this item stays unchecked until then.)
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///). (No public API changed; only an explanatory code comment was added.)
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in flutter/website (or verified none is needed).
  • 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.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

@github-actions

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Oct 29, 2026
@google-cla

google-cla Bot commented Oct 29, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material_ui] showModalBottomSheet(useSafeArea: true) subtracts the opposite safe area from a sheet on a display-feature sub-screen

1 participant