Skip to content

ModalBottomSheetRoute: Content can't consume top notch with SafeArea #121752

@chrisbobbe

Description

@chrisbobbe

Steps to Reproduce

  1. Execute flutter run on the code sample, choosing a recent iPhone with a camera notch (such as an iPhone 14 Pro)
  2. Tap the "Show sheet" button
  3. Bug: The contents of the sheet aren't padded against the notch at the top, even though I've wrapped them in a SafeArea with top: true.

Expected results: I expected my SafeArea to pad the notch at the top, so my sheet's content isn't hidden.

Actual results: My SafeArea did not pad the notch at the top.

Screen recording:

Code sample: https://github.com/chrisbobbe/modal-bottom-sheet-top-inset-not-paddable

Or paste into a blank project's main.dart:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Bottom sheet issue'),
        ),
        body: Center(child: Builder(builder: (context) {
          return ElevatedButton(
            onPressed: () => showModalBottomSheet(
              context: context,
              constraints: const BoxConstraints(minHeight: 800),
              useSafeArea: false,
              isScrollControlled: true,
              builder: (BuildContext context) {
                return SafeArea(
                  child: Column(
                    children: List.generate(4, (index) {
                      return MenuItemButton(
                          onPressed: () {},
                          child: Text('MenuItemButton $index'));
                    })));
              }),
            child: const Text('Show sheet'));
        })),
      ),
    );
  }
}
Logs
No errors expected or observed in the logs.
$ flutter analyze
Analyzing scratch...                                                    
No issues found! (ran in 1.9s)
$ flutter doctor -v
[✓] Flutter (Channel main, 3.8.0-17.0.pre.27, on macOS 13.0 22A380 darwin-x64, locale
    en-US)
    • Flutter version 3.8.0-17.0.pre.27 on channel main at
      /Users/chrisbobbe/.local/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a6f7cd0650 (2 days ago), 2023-02-27 16:30:46 -0800
    • Engine revision 8857c39c96
    • Dart version 3.0.0 (build 3.0.0-277.0.dev)
    • DevTools version 2.22.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/chrisbobbe/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • ANDROID_HOME = /Users/chrisbobbe/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.75.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0 22A380 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 110.0.5481.177

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

• No issues found!
chrisbobbe:~/dev/scratch (main) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: solvedIssue is closed as solvedteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions