Skip to content

showModalBottomSheet not respecting safearea with android:windowTranslucentNavigation #48677

Closed

Description

@sgehrman

I set my main window to
true
to get translucent appBar. If I turn this off, it works fine.

Everything seems to work fine except for showModalBottomSheet which will be positioned too low and behind the system navigation bar.

latest flutter, all packages on latest versions.

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Linux, locale en_US.UTF-8)
• Flutter version 1.12.13+hotfix.5 at /home/steve/google/flutter
• Framework revision 27321eb (5 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e
• Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /home/steve/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /home/steve/google/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Android Studio (version 3.5)
• Android Studio at /home/steve/google/android-studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1)
• VS Code at /usr/share/code
• Flutter extension version 3.7.1

[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

Activity

  1. sgehrman commented on Jan 12, 2020

    @sgehrman
    Author
  2. VladyslavBondarenko commented on Jan 13, 2020

    @VladyslavBondarenko

    Hi @sgehrman
    You can manually receive height of this navigation via MediaQuery.of(context).viewInsets.bottom and use it for adding needed padding/margin

    This is my code sample
    import 'package:flutter/material.dart';
    
    void main() => runApp(MyApp());
    
    class MyApp extends StatelessWidget {
      const MyApp({Key key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) => MaterialApp(
            home: MyHomePage(),
          );
    }
    
    class MyHomePage extends StatefulWidget {
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('Modal bottom sheet'),
          ),
          body: SafeArea(
            child: Center(
              child: RaisedButton(
                child: const Text('SHOW BOTTOM SHEET'),
                onPressed: () {
                  showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
                    return Container(
                    margin: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
                      child: Padding(
                        padding: const EdgeInsets.all(32.0),
                        child: Text('This is the modal bottom sheet. Slide down to dismiss.',
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            color: Theme.of(context).accentColor,
                            fontSize: 24.0,
                          ),
                        ),
                      ),
                    );
                  });
                },
              ),
            ),
          ),
        );
      }
    }
    
  3. added
    d: api docsIssues with https://api.flutter.dev/
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Jan 13, 2020
  4. sgehrman commented on Jan 22, 2020

    @sgehrman
    Author
  5. MalteMagnussen commented on Aug 11, 2020

    @MalteMagnussen

    Having this issue as well.
    Not sure how I'd get safeArea on this, so the top isn't hitting the status bar.
    I tried wrapping various things, such as the BottomModalSheet itself, in SafeArea, but no luck.
    image

  6. ThiagoFontes commented on Dec 7, 2020

    @ThiagoFontes

    If you create a new MaterialApp you'll be able to use SafeArea again, so far it was the only way I was able to

    Working example for me with modal bottomsheets:

    showModalBottomSheet<void>(
          isScrollControlled: true,
          context: context,
          MaterialApp(
                key: _navigationKey,
                onGenerateRoute: _onGenerateRoute,
                navigatorObservers: [_ObserverBottomSheets<T>()],
          ),
    );
  7. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jul 21, 2022
  8. github-actions commented on Aug 4, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Aug 4, 2022
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

    d: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions