Skip to content

OverlayPortalEnty has no way to avoid system intrusions #138836

@caseycrogers

Description

@caseycrogers

Is there an existing issue for this?

Steps to reproduce

  1. Wrap a fullscreen OverlayPortal in SafeArea
  2. Use an overlay entry wrapped in SafeArea with a Container with a solid color as a child
  3. Show the overlay entry

Expected results

The entry covers all the screen except the system intrusions (eg the system bar)

Actual results

The entry covers the entire screen

This is because the overlay entry inherits context from OverlayPortal which is wrapped in a SafeArea and thus has no system intrusions in its inherited MediaQuery. However, the entry is actually drawn in the nearest Overlay stack which is ABOVE the SafeArea and thus does have system intrusions.

The entry should inherit the Portal's MediaQuery, not just its constraints.

Code sample

Code sample
class OverlayPortalDemo extends StatefulWidget {
  const OverlayPortalDemo({super.key});

  @override
  State<OverlayPortalDemo> createState() => _OverlayPortalDemoState();
}

class _OverlayPortalDemoState extends State<OverlayPortalDemo> {
  final OverlayPortalController controller = OverlayPortalController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.blue,
        body: SafeArea(
          child: OverlayPortal(
            controller: controller,
            overlayChildBuilder: (BuildContext context) {
              return Container(
                color: Colors.red,
              );
            },
            child: Center(
              child: ElevatedButton(
                onPressed: () {
                  controller.toggle();
                },
                child: Text('show portal'),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.16Found to occur in 3.16found in release: 3.17Found to occur in 3.17frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-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