Skip to content

Strange dialog behavior on foldable devices in half-fold mode #171448

Open

Description

@math1man

Steps to reproduce

  1. Open up a standard dialog or bottomsheet using showDialog() or showModalBottomSheet().
  2. Partially fold device so that it is in "half-fold" mode.
  3. Try both horizontal and vertical orientations of half-fold mode.

Expected results

Modal should stay in the same position as it is in the unfolded state. I still need to work with our UX team to determine the exact preferred behavior here, but at a minimum there should be a way to turn this behavior on or off.

Actual results

Modal position is changed based on the position and orientation of the fold.

Code sample

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      floatingActionButton: FloatingActionButton(
        onPressed:
            () => showModalBottomSheet(
              context: context,
              builder:
                  (context) => Padding(
                    padding: const EdgeInsets.all(24),
                    child: Text('Bottom sheet'),
                  ),
            ),
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Fully unfolded with a vertical fold orientation:

Image

Half-folded with a vertical fold orientation:

Image

Fully unfolded with a horizontal fold orientation:

Image

Half-folded with a horizontal fold orientation:

Image

Logs

Logs: N/A

Flutter Doctor output

Doctor output
[✓] Flutter (Channel REDACTED, on Debian GNU/Linux REDACTED, locale en_US.UTF-8) [1ms]
    • Framework revision 75a77fec8c (13 days ago), 2025-06-18T00:00:00.000
    • Engine revision 75a77fec8c
    • Dart version b32559bca3

[✓] Android toolchain - develop for Android devices (Android SDK version Stable) [119ms]
    • Android SDK at REDACTED
    • Emulator version unknown
    • Platform Stable, build-tools Stable
    • Java binary at: REDACTED
      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.6+-13368085-b895.109)

[!] Flutter IDE Support (No supported IDEs installed) [116ms]
    • IntelliJ - https://www.jetbrains.com/idea/
    • Android Studio - https://developer.android.com/studio/
    • VS Code - https://code.visualstudio.com/

[✓] Connected device (2 available) [217ms]
    • Pixel Fold (mobile) • REDACTED • android-arm64 • Android 16 (API 36)
    • Linux (desktop)     • linux          • linux-x64     • Debian GNU/Linux REDACTED

Activity

  1. math1man commented on Jul 1, 2025

    @math1man
    ContributorAuthor

    Oh, one other thing. I was also wonder how the Flutter framework configures this behavior. Is there a public API that apps could use to configure similar behavior if desired?

  2. math1man commented on Jul 1, 2025

    @math1man
    ContributorAuthor

    Oh, yet another thing. I noticed that the transition between the unfolded and half-folded states has no animation. It seems like at the very least, Flutter should apply some sort of slide transition to move the modal between the two locations.

  3. math1man commented on Jul 8, 2025

    @math1man
    ContributorAuthor

    Found out that this is based on https://api.flutter.dev/flutter/widgets/MediaQueryData/displayFeatures.html and https://api.flutter.dev/flutter/widgets/DisplayFeatureSubScreen-class.html. Both showModalBottomSheet() and showDialog() have an anchorPoint argument that gets passed to DisplayFeatureSubScreen to control which subscreen the modal will render on. However, there's still one feature gap. My team would like to be able to render a bottom sheet that spans both subscreens. It seems like there is currently no way to achieve this with the showModalBottomSheet() method. I investigated copying the MediaQueryData to remove the DisplayFeatures, but the context that the bottom sheet uses to obtain the DisplayFeatures comes from the Navigator, so there's no way to remove them discriminately.

  4. math1man commented on Jul 8, 2025

    @math1man
    ContributorAuthor

    I also confirmed that changing this Padding widget to an AnimatedPadding widget improves the transition, though there's still some animation jank due to changes to the SafeArea that is applied directly in the bottom sheet logic.

  5. added
    P2Important issues not at the top of the work list
    on Jul 8, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions