Repository navigation
Description
Steps to reproduce
- Use a window with a hinge
DisplayFeatureand a side safe area, e.g. a foldable held as a book with the status bar on the right (iPhone Duo simulator, Xcode 27.1, iOS 27.1, inner display 951 × 669 pt). - Call
showModalBottomSheet(useSafeArea: true, anchorPoint: …)with an anchor on the left sub-screen. - Run the test below.
Expected results
The sheet fills the left sub-screen: 455.5 pt wide. That sub-screen does not touch the right safe area, so nothing should be subtracted.
Actual results
The sheet is 375.5 pt wide. The right inset (80 pt) of the window is subtracted from the left sub-screen as well. With useSafeArea: false the width is 455.5 pt.
In the iPhone Duo simulator (Xcode 27.1 Device Hub, book posture, status bar on the right), a left sheet is about 372 pt wide instead of 455 pt. A dimmed strip is left between the sheet and the hinge.
Cause
ModalBottomSheetRoute.buildPage wraps the DisplayFeatureSubScreen in the SafeArea:
final Widget content = DisplayFeatureSubScreen(anchorPoint: anchorPoint, child: …);
Widget bottomSheet = useSafeArea
? SafeArea(bottom: false, child: content)
: MediaQuery.removePadding(context: context, removeTop: true, child: content);SafeArea shrinks the constraints but keeps MediaQuery.size. DisplayFeatureSubScreen therefore pads to the sub-screen in full-window coordinates (right: parentSize.width - subScreen.right) inside a box that is already narrower by the inset.
RawDialogRoute (showDialog) applies its SafeArea inside DisplayFeatureSubScreen. There, MediaQueryData.removeDisplayFeatures already gives each sub-screen only the padding of its own edges. Putting the sheet's SafeArea inside the sub-screen in the same way would fix this.
Code sample
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('a sheet on the left sub-screen keeps its width', (tester) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = const Size(951, 669);
tester.view.padding = const FakeViewPadding(right: 80);
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
builder: (context, child) => MediaQuery(
data: MediaQuery.of(context).copyWith(
displayFeatures: const <DisplayFeature>[
DisplayFeature(
bounds: Rect.fromLTWH(455.5, 0, 40, 669),
type: DisplayFeatureType.hinge,
state: DisplayFeatureState.postureHalfOpened,
),
],
),
child: child!,
),
home: Builder(
builder: (context) => Scaffold(
body: Align(
alignment: Alignment.topLeft,
child: ElevatedButton(
onPressed: () => showModalBottomSheet<void>(
context: context,
useSafeArea: true,
anchorPoint: const Offset(100, 669),
builder: (_) =>
const SizedBox(height: 200, child: Placeholder()),
),
child: const Text('open'),
),
),
),
),
),
);
await tester.tap(find.text('open'));
await tester.pumpAndSettle();
// Fails: actual width is 375.5.
expect(tester.getSize(find.byType(Placeholder)).width, 455.5);
});
}The same happens vertically. In a 669 × 951 window with a 24 pt top inset and a horizontal hinge at y 455.5 (tabletop), a tall isScrollControlled sheet on the lower sub-screen starts at y 519.5 instead of 495.5. It loses the top inset that belongs to the other sub-screen.
Flutter version
Flutter 3.47.7 • channel stable • https://github.com/flutter/flutter.git
Framework • revision abaf9c5237 • 2026-10-08 09:51:21 -0700
Engine • hash d8a2d6c768c334d53e16277f837970ffa1e2de81 (revision deb287481e)
Tools • Dart 3.13.5 • DevTools 2.60.0
The widget test fails on macOS. Device check: iPhone Duo simulator, iOS 27.1. The wrapping is unchanged on master.
Related, but not the same: #121554 (gap below the sheet with useSafeArea), #175379 (extra side margin in landscape on Android), #192667 (MediaQuery.sizeOf inside a sub-screen reports the whole window).
Activity
saurabh-mirajkar commentedon Oct 26, 2026
@4KDV Thanks for the detailed report. I reproduced this on Flutter 3.47.8 stable. Routing this to the design team for evaluation.
[-]`showModalBottomSheet(useSafeArea: true)` subtracts the opposite safe area from a sheet on a display-feature sub-screen[/-][+][material_ui] `showModalBottomSheet(useSafeArea: true)` subtracts the opposite safe area from a sheet on a display-feature sub-screen[/+][material_ui] Fix showModalBottomSheet safe area on display-feature s…
[material_ui] Fix ModalBottomSheet subtracting opposite sub-screen sa…