Skip to content

Can not showModalBottomSheet using PopupMenuButton #127443

@mhbdev

Description

@mhbdev

Is there an existing issue for this?

Steps to reproduce

  1. Create a simple Materal Themed application
  2. Use Scaffold and give it an AppBar with actions property
  3. Use the code in sample section to implement AppBar
  4. Tap on the IconButton and you can see that the bottom sheet is going to appear
  5. Tap on the PopupMenuButton and then tap on SHOW and nothing is going to happen.

Expected results

Expected PopupMenuItem to show the bottom sheet

Actual results

Bottom sheet is not showing but something odd is happening.
Try to put e Future delay before openning the bottomsheet:

                    Future.delayed(Duration(seconds: 2)).then((value) {
                      showModalBottomSheet(
                        context: context,
                        useSafeArea: true,
                        isScrollControlled: true,
                        shape: const RoundedRectangleBorder(
                            borderRadius: BorderRadius.vertical(top: Radius.circular(16))),
                        builder: (context) {
                          return const Placeholder();
                        },
                      );
                    });

Now it works!!!

Code sample

Code sample
AppBar(
        title: const Text('Title'),
        actions: [
          IconButton(
              onPressed: () {
                showModalBottomSheet(
                  context: context,
                  useSafeArea: true,
                  isScrollControlled: true,
                  shape: const RoundedRectangleBorder(
                      borderRadius: BorderRadius.vertical(top: Radius.circular(16))),
                  builder: (context) {
                    return const Placeholder();
                  },
                );
              },
              icon: Icon(Icons.close)),
          Builder(
            builder: (context) => PopupMenuButton(
              padding: EdgeInsets.zero,
              itemBuilder: (context) => [
                PopupMenuItem(
                  padding: const EdgeInsets.symmetric(horizontal: 8),
                  onTap: () {
                      showModalBottomSheet(
                        context: context,
                        useSafeArea: true,
                        isScrollControlled: true,
                        shape: const RoundedRectangleBorder(
                            borderRadius: BorderRadius.vertical(top: Radius.circular(16))),
                        builder: (context) {
                          return const Placeholder();
                        },
                      );
                  },
                  child: Text('SHOW'),
                ),
              ],
              child: const Padding(padding: EdgeInsets.all(16), child: Icon(Icons.more_vert)),
            ),
          ),
        ],
      )

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.19045.2846], locale en-US)
    • Flutter version 3.10.0 on channel stable at C:\FlutterStable\flutter  
    • Upstream repository https://github.com/flutter/flutter.git            
    • Framework revision 84a1e904f4 (2 weeks ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9                                            
    • Dart version 3.0.0                                                    
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\AndroidSdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33627.172
    • Windows 10 SDK version 10.0.20348.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • 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 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.78.2)
    • VS Code at C:\Users\MonoBit\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.64.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.2846]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 113.0.5672.127
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 112.0.1722.39

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    f: material designflutter/packages/flutter/material repository.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions