Skip to content

CupertinoSheetRoute content extends beyond screen & affects hero animation #164087

Closed

Description

@hm21

Steps to reproduce

  1. Copy and paste the example code below, which is a minimally modified version of the official example from the Flutter documentation.
  2. Tap the “Open Bottom Sheet” button.
  3. Notice that the FlutterLogo widget is not fully visible.
  4. (Optional) Uncomment the “Scroll Example” or “Hero Example” to observe the same issue in different scenarios.

I tested this using the Pixel 8 Pro emulator on Android and encountered the same issue on other platforms, including Windows and the web (Chrome).

Expected results

The entire content of the CupertinoSheetRoute should be fully visible.

Actual results

  • The bottom of the CupertinoSheetRoute extends beyond the screen, and the height of the portion outside the screen varies, likely due to changes in the device height.
  • Interestingly, the hero animation also seems to be affected by this issue, as shown in the video below—the widget makes a sudden jump after the animation is complete.

Code sample

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

/// Flutter code sample for [CupertinoSheetRoute].

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

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

  @override
  Widget build(BuildContext context) {
    return const CupertinoApp(
      theme: CupertinoThemeData(brightness: Brightness.light),
      title: 'Cupertino Sheet',
      home: HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      navigationBar: const CupertinoNavigationBar(
        middle: Text('Sheet Example'),
        automaticBackgroundVisibility: false,
      ),
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            CupertinoButton.filled(
              onPressed: () {
                Navigator.of(context).push(
                  CupertinoSheetRoute<void>(
                    builder: (BuildContext context) => const _SheetScaffold(),
                  ),
                );
              },
              child: const Text('Open Bottom Sheet'),
            ),
          ],
        ),
      ),
    );
  }
}

class _SheetScaffold extends StatelessWidget {
  const _SheetScaffold();

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Stack(
        alignment: Alignment.bottomCenter,
        children: [
          GestureDetector(onTap: () {
            if (CupertinoSheetRoute.hasParentSheet(context)) {
              CupertinoSheetRoute.popSheet(context);
            } else {
              Navigator.pop(context);
            }
          }),
          Container(
            clipBehavior: Clip.hardEdge,
            width: double.infinity,
            decoration: BoxDecoration(
              color: Theme.of(context).cardColor,
              borderRadius: const BorderRadius.vertical(
                top: Radius.circular(12),
              ),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withAlpha(80),
                  spreadRadius: 10,
                  blurRadius: 10,
                  offset: const Offset(0, 7),
                ),
              ],
            ),
            child: const FlutterLogo(size: 200),
          ),
        ],
      ),
    );

    /*
    TODO: Scroll example
    Test with `CupertinoPageScaffold` but same result:
     
    return CupertinoPageScaffold(
      child: Scrollbar(
        thumbVisibility: true,
        trackVisibility: true,
        child: ListView.builder(
          physics: const ClampingScrollPhysics(),
          itemCount: 7,
          itemBuilder: (context, index) {
            return Container(
              color: Colors.amber,
              child: const FlutterLogo(size: 200),
            );
          },
        ),
      ),
    );
 */
    /* 
    TODO: Hero example
    return CupertinoPageScaffold(
      child: Center(
        child: GestureDetector(
          onTap: () {
            Navigator.push(
              context,
              CupertinoPageRoute(
                builder: (_) {
                  return const CupertinoPageScaffold(
                    navigationBar: CupertinoNavigationBar(
                      automaticBackgroundVisibility: false,
                    ),
                    child: SafeArea(
                      child: Align(
                        alignment: Alignment.topCenter,
                        child: Hero(
                          tag: 'test',
                          child: FlutterLogo(size: 200),
                        ),
                      ),
                    ),
                  );
                },
              ),
            );
          },
          child: const Hero(
            tag: 'test',
            child: FlutterLogo(size: 200),
          ),
        ),
      ),
    );
     */
  }
}

Screenshots or Video

Screenshots / Video demonstration
Simple.mp4
Scroll.mp4
Hero.mp4

Logs

No response

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.29.0, on Microsoft Windows [Version 10.0.26100.3194], locale de-CH) [791ms]
    • Flutter version 3.29.0 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (2 weeks ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[√] Windows Version (11 Home 64-bit, 24H2, 2009) [5.1s]

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [4.6s]
    • Android SDK at C:\Users\AlexF\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = C:\Users\AlexF\AppData\Local\Android\Sdk
    • ANDROID_SDK_ROOT = C:\Users\AlexF\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio1\jbr\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 17.0.10+0--11572160)
    • All Android licenses accepted.

[√] Chrome - develop for the web [171ms]
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.0) [169ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33414.496
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2023.3) [38ms]
    • Android Studio at C:\Program Files\Android\Android Studio1
    • 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 17.0.10+0--11572160)

[√] VS Code (version 1.97.2) [36ms]
    • VS Code at C:\Users\AlexF\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.104.0

[√] Connected device (3 available) [622ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.3194]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 133.0.6943.127
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 132.0.2957.127

[√] Network resources [642ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. maheshj01 commented on Feb 26, 2025

    @maheshj01
    Member

    Hello @hm21, Thanks for filing the detailed issue. Reproducible on latest stable and the master channel. I am quite not sure whether the jump in hero animation is related to this issue. Incase it is not we should file it separately,

    flutter doctor -v
    [✓] Flutter (Channel master, 3.30.0-1.0.pre.330, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US) [5.9s]
        • Flutter version 3.30.0-1.0.pre.330 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 99e1a0652c (2 hours ago), 2025-02-25 16:59:54 -0800
        • Engine revision 99e1a0652c
        • Dart version 3.8.0 (build 3.8.0-133.0.dev)
        • DevTools version 2.43.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1,735ms]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 34.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 17.0.11+0-17.0.11b1207.24-11852314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,082ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [121ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.1) [120ms]
        • 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 17.0.11+0-17.0.11b1207.24-11852314)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [119ms]
        • 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) [17ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (3 available) [6.5s]
        • Iphone 13 (mobile) • 6DE09AA3-2245-457B-AF8D-8FCB01009014 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-4 (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 [328ms]
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel stable, 3.29.0, on macOS 15.1.1 24B2091 darwin-arm64, locale en-US)
        [594ms]
        • Flutter version 3.29.0 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 35c388afb5 (2 weeks ago), 2025-02-10 12:48:41 -0800
        • Engine revision f73bfc4522
        • Dart version 3.7.0
        • DevTools version 2.42.2
        • 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 34.0.0)
        [1,848ms]
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-35, build-tools 34.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 17.0.11+0-17.0.11b1207.24-11852314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [1,146ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 16A242d
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [142ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.1) [141ms]
        • 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 17.0.11+0-17.0.11b1207.24-11852314)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1) [140ms]
        • 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) [25ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.102.0
    
    [✓] Connected device (4 available) [6.5s]
        • Iphone 13 (mobile)              • 6DE09AA3-2245-457B-AF8D-8FCB01009014 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-15-4 (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 [389ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: cupertino_uicupertino_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Feb 26, 2025
  3. TahaTesser commented on Mar 11, 2025

    @TahaTesser
    Contributor

    @maheshj01 Please label Cupertino widget issues with team-design since this is not a core framework widget.

  4. added
    team-designOwned by Design Languages team
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Mar 11, 2025
  5. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Mar 12, 2025
  6. igor-kualia commented on Mar 28, 2025

    @igor-kualia

    I think it has something to do with the extra padding at the top. You can notice the extra padding when you add an AppBar to your Scaffold. Or see an example in this duplicate-closed issue: #164779 (comment)

  7. added a commit that references this issue on Apr 15, 2025
    2f30429
  8. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 16, 2025
  9. added a commit that references this issue on Apr 16, 2025
    6c6dbb2
  10. added a commit that references this issue on Apr 21, 2025
    b73d809
  11. github-actions commented on Apr 30, 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.

  12. locked as resolved and limited conversation to collaborators on Apr 30, 2025
  13. added a commit that references this issue on Aug 14, 2025
    b0bcedb
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 listfound in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions