Skip to content

Modal bottom sheet is not dismissible when using FadeForwardsPageTransitionsBuilder #165681

Closed

Description

@julien4215

Steps to reproduce

  1. Show a bottom sheet using showModalBottomSheet
  2. Push a new route
  3. Pop the route
  4. Notice that the modal bottom sheet is not dismissible

Expected results

The bottom sheet should be dismissible.

Actual results

The bottom sheet is not dismissible.

Code sample

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

void main() => runApp(const App());

class App extends StatefulWidget {
  const App({super.key});

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  bool useFadeTransition = false;

  void togglePageTransitionType() {
    setState(() {
      useFadeTransition = !useFadeTransition;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme:
          useFadeTransition
              ? ThemeData(
                pageTransitionsTheme: PageTransitionsTheme(
                  builders:
                      Map<TargetPlatform, PageTransitionsBuilder>.fromIterable(
                        TargetPlatform.values,
                        value:
                            (_) => const FadeForwardsPageTransitionsBuilder(),
                      ),
                ),
              )
              : null,
      home: FirstPage(
        useFadeTransition: useFadeTransition,
        togglePageTransitionType: togglePageTransitionType,
      ),
    );
  }
}

class FirstPage extends StatelessWidget {
  final bool useFadeTransition;
  final VoidCallback togglePageTransitionType;

  const FirstPage({
    super.key,
    required this.useFadeTransition,
    required this.togglePageTransitionType,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('First Page')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Current Page Transition Type:\n${useFadeTransition ? 'FadeForwardsPageTransitionsBuilder' : 'Default (ZoomPageTransitionsBuilder)'}',
              textAlign: TextAlign.center,
            ),
            ElevatedButton(
              onPressed: togglePageTransitionType,
              child: Text('Toggle Page Transition Type'),
            ),
            ElevatedButton(
              child: Text('Open Modal BottomSheet'),
              onPressed: () {
                showModalBottomSheet(
                  context: context,
                  builder:
                      (context) => Container(
                        height: 200,
                        color: Colors.amber,
                        child: Center(
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            mainAxisSize: MainAxisSize.min,
                            children: <Widget>[
                              const Text('Modal BottomSheet'),
                              ElevatedButton(
                                child: const Text('Second Page'),
                                onPressed:
                                    () => Navigator.of(context).push(
                                      MaterialPageRoute<SecondPage>(
                                        builder:
                                            (BuildContext context) =>
                                                SecondPage(),
                                      ),
                                    ),
                              ),
                            ],
                          ),
                        ),
                      ),
                );
              },
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(appBar: AppBar(title: Text('Second Page')));
  }
}

Video

Video demonstration
flutter-bug.webm

Flutter version

Flutter version
Flutter 3.31.0-0.1.pre

Activity

  1. maheshj01 commented on Mar 21, 2025

    @maheshj01
    Member

    Reproducible on stable and the master channel. It looks like the bottomsheet is popped but the barrier is still present
    On the master channel the bottom sheet is not dismissable, This is an issue when using FadeForwardsPageTransitionsBuilder and works fine when using other transitionBuilders such as FadeUpwardsPageTransitionsBuilder

    with pageTransitionsTheme(stable) Without pageTransitionsTheme with pageTransitionsTheme(master)
    Screen.Recording.2025-03-21.at.19.28.16.mov
    Screen.Recording.2025-03-21.at.19.30.30.mov
    Screen.Recording.2025-03-21.at.19.35.12.mov
    minimal reproducible code
    import 'package:flutter/material.dart';
    
    void main() => runApp(const App());
    
    class App extends StatefulWidget {
      const App({super.key});
    
      @override
      State<App> createState() => _AppState();
    }
    
    class _AppState extends State<App> {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData(
            pageTransitionsTheme: PageTransitionsTheme(
              builders: Map<TargetPlatform, PageTransitionsBuilder>.fromIterable(
                TargetPlatform.values,
                value: (_) => const FadeForwardsPageTransitionsBuilder(),
              ),
            ),
          ),
          home: FirstPage(),
        );
      }
    }
    
    class FirstPage extends StatelessWidget {
      const FirstPage({
        super.key,
      });
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text('First Page')),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text(
                  'Transition Type:FadeForwardsPageTransitionsBuilder',
                  textAlign: TextAlign.center,
                ),
                ElevatedButton(
                  child: Text('Open Modal BottomSheet'),
                  onPressed: () {
                    showModalBottomSheet(
                      context: context,
                      barrierLabel: 'Modal BottomSheet',
                      builder: (context) => Center(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          mainAxisSize: MainAxisSize.min,
                          children: <Widget>[
                            const Text('Modal BottomSheet'),
                            ElevatedButton(
                              child: const Text('Second Page'),
                              onPressed: () {
                                Navigator.of(context).push(
                                  MaterialPageRoute<SecondPage>(
                                    builder: (BuildContext context) => SecondPage(),
                                  ),
                                );
                              },
                            ),
                          ],
                        ),
                      ),
                    );
                  },
                ),
              ],
            ),
          ),
        );
      }
    }
    
    class SecondPage extends StatelessWidget {
      const SecondPage({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(appBar: AppBar(title: Text('Second Page')));
      }
    }
    
    flutter doctor -v
    [✓] Flutter (Channel master, 3.31.0-1.0.pre.177, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [2.5s]
        • Flutter version 3.31.0-1.0.pre.177 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 1cf57f1eaa (61 minutes ago), 2025-03-21 22:30:47 +0000
        • Engine revision 1cf57f1eaa
        • Dart version 3.8.0 (build 3.8.0-210.0.dev)
        • DevTools version 2.45.0-dev.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,534ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [137ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [136ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [135ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [18ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (3 available) [7.6s]
        • iPhone 16 Pro (mobile) • 34497AEA-B6B0-4F79-99A3-6E40007745A3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0
          (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [422ms]
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel stable, 3.29.2, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [625ms]
        • Flutter version 3.29.2 on channel stable at /Users/mahesh/Development/flutter
        ! Warning: `flutter` on your path resolves to /Users/mahesh/Development/flutter_master/bin/flutter, which is not inside your
          current Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to
          the front of your path.
        ! Warning: `dart` on your path resolves to /Users/mahesh/Development/flutter_master/bin/dart, which is not inside your current
          Flutter SDK checkout at /Users/mahesh/Development/flutter. Consider adding /Users/mahesh/Development/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision c236373904 (8 days ago), 2025-03-13 16:17:06 -0400
        • Engine revision 18b71d647a
        • Dart version 3.7.2
        • DevTools version 2.42.3
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform
          update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,926ms]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 35.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/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+-12932927-b750.29)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,231ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [138ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.3) [137ms]
        • 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 21.0.5+-12932927-b750.29)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [136ms]
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.96.2) [18ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.6s]
        • iPhone 16 Pro (mobile)          • 34497AEA-B6B0-4F79-99A3-6E40007745A3 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
        • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.1.1 24B2091 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.1.1 24B2091 darwin-arm64
        • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.265
    
    [✓] Network resources [1,091ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    p: material_uimaterial_ui package in flutter/packages
    f: routesNavigator, Router, and related APIs.
    and removed
    in triagePresently being triaged by the triage team
    on Mar 21, 2025
  3. added
    P2Important issues not at the top of the work list
    on Mar 25, 2025
  4. MitchellGoodwin commented on Apr 10, 2025

    @MitchellGoodwin
    Contributor

    Testing on master I'm able to dismiss the bottom sheet by tapping the barrier after returning from a FadeForwardsPageTransitionBuilder.

    Closing as fixed as a part of ##164675

  5. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 10, 2025
  6. github-actions commented on Apr 25, 2025

    @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.

  7. locked as resolved and limited conversation to collaborators on Apr 25, 2025
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 listf: routesNavigator, Router, and related APIs.found in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions