Skip to content

Modal bottom sheet is not dismissible when using FadeForwardsPageTransitionsBuilder #165681

@julien4215

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.f: 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 onr: 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