Skip to content

CupertinoSheet page content taking wrong MediaQuery values #167943

@CoderNamedHendrick

Description

@CoderNamedHendrick

Steps to reproduce

Use widgets that use MediaQuery properties to constrain their size/position, like Appbar and SafeArea in the pageBuilder of the showCupertinoSheet function.

Expected results

  • Widgets wrapped in safe area should be visible and not go under the screen
  • Appbar should be aligned to the top since there's no top padding for the sheet content.

Actual results

  • Widgets wrapped in SafeArea go under the visible area of the screen
  • Appbar is aligned wrongly since MediaQuery padding has a non-zero value.

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(
        builder: (context) {
          return Scaffold(
            appBar: AppBar(
              backgroundColor: Theme.of(context).colorScheme.inversePrimary,
              title: Text('Show cupertino sheet demo'),
            ),
            body: Center(
              child: ElevatedButton(
                onPressed: () {
                  showCupertinoSheet(
                    context: context,
                    pageBuilder: (context) {
                      Widget child = SafeArea(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Container(
                              height: 80,
                              width: double.infinity,
                              color: Colors.pink,
                            ),
                            Container(
                              height: 80,
                              width: double.infinity,
                              color: Colors.green,
                            ),
                          ],
                        ),
                      );

                      // return CupertinoPageScaffold(
                      //   navigationBar: CupertinoNavigationBar(previousPageTitle: 'Hello'),
                      //   child: child,
                      // );
                      return Scaffold(
                        appBar: AppBar(title: Text('Hello')),
                        body: child,
                      );
                    },
                  );
                },
                child: Text('Open cupertino bottom sheet'),
              ),
            ),
          );
        },
      ),
    );
  }
}

Screenshots or Video

Scaffold and CupertinoPageScaffold screenshots from the above code sample

Image

Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4 24E248 darwin-arm64, locale en-NG) [2.6s]
    • Flutter version 3.29.3 on channel stable at /Users/sebastine/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (2 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [6.8s]
    • Android SDK at /Users/sebastine/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Users/sebastine/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.6+-13355223-b631.42)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.3) [1,577ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    ! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

[✓] Chrome - develop for the web [337ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [337ms]
    • Android Studio at /Users/sebastine/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.6+-13355223-b631.42)

[✓] Android Studio (version 2024.2) [334ms]
    • Android Studio at /Users/sebastine/Library/Caches/JetBrains/Toolbox/backup/AndroidStudio-242.23726.103.2422.13016713-4739872658208990322/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 Ultimate Edition (version 2025.1) [334ms]
    • IntelliJ at /Users/sebastine/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 85.2.4
    • Dart plugin version 251.25267.1

[✓] VS Code (version 1.99.2) [16ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] Connected device (4 available) [6.9s]
    • iPhone 15 Pro (mobile)          • 324C2CAF-F3BD-4D88-997B-BCECB503FB34 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4 24E248 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 135.0.7049.115
    ! Error: Browsing on the local area network for Sebastine’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [1,200ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: cupertinoflutter/packages/flutter/cupertino repositoryfound in release: 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32frameworkflutter/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-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions