Skip to content

Persistent bottom sheet does not respect SafeArea #69676

Open

Description

@amitkot

When showing a persistent bottom sheet SafeArea is ignored and does not provide bottom padding:

Screen Shot 2020-11-03 at 16 18 04

Code:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(home: MyHomePage());
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key key}) : super(key: key);
  @override
  Widget build(BuildContext context) => Scaffold(
        floatingActionButton: Builder(
          builder: (context) => FloatingActionButton(
            onPressed: () {
              showBottomSheet(
                  context: context,
                  builder: (context) => SafeArea(
                        child: Container(
                          height: 100,
                          width: 200,
                          color: Colors.red,
                        ),
                      ));
            },
          ),
        ),
      );
}
[✓] Flutter (Channel stable, 1.22.2, on Mac OS X 10.14.6 18G6032, locale en-IL)
    • Flutter version 1.22.2 at /Users/amit/fvm/versions/stable
    • Framework revision 84f3d28555 (3 weeks ago), 2020-10-15 16:26:19 -0700
    • Engine revision b8752bbfff
    • Dart version 2.10.2

Activity

  1. changed the title [-]Persistent bottom sheet does not respect `SafeArea`[/-] [+]Persistent bottom sheet does not respect SafeArea[/+] on Nov 3, 2020
  2. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Nov 3, 2020
  3. pedromassangocode commented on Nov 5, 2020

    @pedromassangocode

    Reproducible on latest master as well.

    flutter doctor -v
    [✓] Flutter (Channel master, 1.24.0-8.0.pre.97, on Mac OS X 10.15.7 19H2 darwin-x64, locale en)
        • Flutter version 1.24.0-8.0.pre.97 at /Users/pedromassango/dev/SDKs/flutter_master
        • Framework revision 4c24eb10b8 (72 minutes ago), 2020-11-05 11:18:00 +0100
        • Engine revision e66a720137
        • Dart version 2.12.0 (build 2.12.0-21.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
        • Android SDK at /Users/pedromassango/Library/Android/sdk
        • Platform android-30, build-tools 30.0.1
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.1, Build version 12A7403
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.0)
        • 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 1.8.0_242-release-1644-b3-6222593)
    
    [✓] IntelliJ IDEA Community Edition (version 2020.2.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 50.0
        • Dart plugin version 202.7319.5
    
    [✓] VS Code (version 1.50.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.16.0
    
    [✓] Connected device (4 available)
        • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
        • macOS (desktop)             • macos         • darwin-x64     • Mac OS X 10.15.7 19H2 darwin-x64
        • Web Server (web)            • web-server    • web-javascript • Flutter Tools
        • Chrome (web)                • chrome        • web-javascript • Google Chrome 86.0.4240.183
    
    • No issues found!
    
  4. zepfietje commented on Dec 2, 2020

    @zepfietje

    The same issue occurs when directly setting the bottomSheet property of Scaffold.

    Scaffold(
      bottomSheet: SafeArea(
        // ...
      ),
    )
  5. noelmansour commented on Aug 3, 2021

    @noelmansour

    This top safe area is also not respected as outlined in this stackoverflow post.

    The suggested answer is to copy the BottomSheet widget and update the build method to remove the MediaQuery.removePadding widget.

  6. tmaihoff commented on Nov 6, 2021

    @tmaihoff

    Any updates here? Still having this issue

  7. Arenukvern commented on Nov 24, 2021

    @Arenukvern

    Faced this issue too with top-notch.

    Resolved using dart:ui.window.viewPadding.top / ui.window.devicePixelRatio

    How it works:
    The dart:ui.window.viewPadding is the number of physical pixels on each side of the display rectangle into which the view can render.
    By dividing to ui.window.devicePixelRatio we should receive logic pixels.

    So in summary code is

    showModalBottomSheet<bool>(
          context: context,
          builder: (BuildContext context) => Container(
            height: MediaQuery.of(context).size.height,
            padding: EdgeInsets.only(
             top: ui.window.viewPadding.top / ui.window.devicePixelRatio,
            ),
          ),
        );
  8. n13 commented on Feb 16, 2022

    @n13

    We are facing this issue as well.

    We have a persistent bottom button on the bottom sheet, but it's too low down on iPhone - SafeArea is ignored.

    Is there a different way to have a persistent bottom button?

  9. 0xHristo commented on May 18, 2022

    @0xHristo

    If you wrap the Scaffold in SafeArea it gets the work done, but if you want SafeArea's horizontal insets on the bottomSheet: you have to add some padding.

  10. StephenWithPH commented on Aug 1, 2023

    @StephenWithPH

    There is a workaround here: #50314 (comment)

    Of note, that issue (#50314) seems to be the same basic issue as this one.

  11. added a commit that references this issue on Jan 26, 2024
  12. added
    d: api docsIssues with https://api.flutter.dev/
    P2Important issues not at the top of the work list
    workaround availableThere is a workaround available to overcome the issue
    on Apr 22, 2025
  13. added a commit that references this issue on Feb 1, 2026
  14. iazel commented on Feb 22, 2026

    @iazel

    The issue still persist for the latest stable release (3.41.0)

  15. added a commit that references this issue on Feb 22, 2026
  16. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    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

    P2Important issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/found in release: 1.22Found to occur in 1.22found in release: 1.24Found to occur in 1.24p: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions