Skip to content

showModalBottomSheet with SafeArea has extra left/right margin on Android in landscape #175379

Open

Description

@jpwoodbu

Steps to reproduce

  1. use showModalBottomSheet() in a callback
  2. wrap the returned Widget with SafeArea()
  3. deploy on Android
  4. rotate device into landscape orientation

Expected results

The bottom sheet should have a width roughly the same as the widget it contains.

Actual results

The bottom sheet has excessive margin on its left side. This was not the case on Linux or Web. I only observed the extra margin on Android in landscape orientation.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() async {
  runApp(MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TextButton(
          onPressed: () {
            showModalBottomSheet(
              context: context,
              builder: (context) {
                return const SafeArea(
                  minimum: EdgeInsets.all(8.0),
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [Text('Foo'), Text('Bar')],
                  ),
                );
              },
            );
          },
          child: Text('Show bottom sheet'),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

On Android with landscape orientation.
Image

On Android with portrait orientation.
Image

Logs

N/A

Flutter Doctor output

Doctor output
$ fvm flutter doctor -v
[✓] Flutter (Channel stable, 3.35.3, on Debian GNU/Linux forky/sid 5.15.133.1-microsoft-standard-WSL2, locale en_US.UTF-8) [37ms]
    • Flutter version 3.35.3 on channel stable at /home/jpwoodbu/fvm/versions/3.35.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a402d9a437 (12 days ago), 2025-09-03 14:54:31 -0700
    • Engine revision ddf47dd3ff
    • Dart version 3.9.2
    • Java binary at: /home/jpwoodbu/Android/android-studio.new/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Chrome - develop for the web [11ms]
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [356ms]
    • Debian clang version 19.1.7 (3+b2)
    • cmake version 3.31.6
    • ninja version 1.12.1
    • pkg-config version 1.8.1
    ! Unable to access driver information using 'eglinfo'.
      It is likely available from your distribution (e.g.: apt install mesa-utils)

[✓] Android Studio (version 2023.3) [8ms]
    • Android Studio at /home/jpwoodbu/Android/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)

[✓] Android Studio (version 2024.3) [7ms]
    • Android Studio at /home/jpwoodbu/Android/android-studio.new
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)

[✓] Connected device (3 available) [620ms]
    • Pixel 8a (mobile) • 192.168.86.67:39551 • android-arm64  • Android 16 (API 36)
    • Linux (desktop)   • linux               • linux-x64      • Debian GNU/Linux forky/sid 5.15.133.1-microsoft-standard-WSL2
    • Chrome (web)      • chrome              • web-javascript • Google Chrome 140.0.7339.127

[✓] Network resources [115ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Activity

  1. added
    in triage
    on Sep 16, 2025
  2. tirth-patel-nc commented on Sep 16, 2025

    @tirth-patel-nc
    Member

    @jpwoodbu thanks for the report. I wasn’t able to reproduce this on either an emulator or a real device (Pixel 6a) in landscape mode using the provided code sample on the latest stable (3.35.3) or the latest master (3.37.0-1.0.pre-132). could you check if the issue still occurs on the latest master? also, is this specific to your device (Pixel 8a), or do you see it elsewhere as well?

    Image Image
  3. added
    waiting for response
    on Sep 16, 2025
  4. jpwoodbu commented on Sep 16, 2025

    @jpwoodbu
    Author

    Thanks for the quick triage! I am able to reproduce this with Flutter 3.37.0-1.0.pre-134 on my physical Pixel 8a and in the emulator using the Pixel 8a profile. The "Medium Phone API 36.0" emulator profile does not reproduce the issue.

    Here's a screenshot with the emulator running the Pixel 8a profile running an APK built with Flutter 3.37.0-1.0.pre-134.

    Image
  5. removed
    waiting for response
    on Sep 16, 2025
  6. jpwoodbu commented on Sep 16, 2025

    @jpwoodbu
    Author

    Oh, to answer your question more directly, I also tried the demo code above on Linux and the issue was not present even with a wide window. I have not tried it on iOS or web. I've only seen the issue on my physical Pixel 8a and the emulated Pixel 8a.

  7. jpwoodbu commented on Sep 17, 2025

    @jpwoodbu
    Author

    I came across some potential clues. The issue is not present in the Pixel 8a emulator if 3-button navigation is enabled.

    Image

    If there is no on-screen camera, like in this Pixel 4 emulator, the issue is not present.

    Image
  8. tirth-patel-nc commented on Sep 17, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions with Gesture Navigation (i.e. disabling 3 button navigation). useSafeArea didn't work either. #69676 might be related

    stable : 3.35.4
    master : 3.37.0-1.0.pre-155
    
  9. added
    team-design
    framework
    p: material_ui
    a: tablet
    has reproducible steps
    found in release: 3.35
    found in release: 3.37
    a: quality
    and removed
    in triage
    on Sep 17, 2025
  10. added
    P2
    triaged-design
    on Sep 17, 2025
  11. changed the title [-]showModalBottomSheet with SafeArea has extra left margin on Android in landscape[/-] [+]showModalBottomSheet with SafeArea has extra left/right margin on Android in landscape[/+] on Sep 29, 2025
  12. tirth-patel-nc commented on Sep 29, 2025

    @tirth-patel-nc
    Member

    extra margin (left/right) depends on the landscape orientation. updating the title. Tested on Physical Pixel 6a/9a.

    Screen.Recording.2025-09-29.at.1.03.21.PM.mov

    cc: @huycozy

  13. added
    package
    and removed
    framework
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2a: qualitya: tabletfound in release: 3.35found in release: 3.37has reproducible stepsp: material_uipackageteam-designtriaged-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions