Skip to content

[iOS] CupertinoSheetRoute doesn't reset SystemUiOverlayStyle when closed #164633

Closed

Description

@GiacomoPignoni

Steps to reproduce

Push a CupertinoSheetRoute and the close it

Expected results

The SystemUiOverlayStyle should return what it was, since CupertinoSheetRoute set it to .light

Actual results

The SystemUiOverlayStyle remain .light causing the status bar being not visibile anymore

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        fontFamily: "CupertinoSystemDisplay",
      ),
      home: const Home(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Center(
          child: FilledButton(
            onPressed: () {
              showCupertinoSheet(
                context: context,
                pageBuilder: (context) {
                  return const Scaffold(
                    body: Center(
                      child: Text('Sheet'),
                    ),
                  );
                },
              );
            },
            child: const Text("Open Sheet"),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-03-05.at.5.15.27.PM.mov

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.30.0-0.1.pre, on macOS 15.3 24D60 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Community Edition (version 2024.3.2.2)
[✓] VS Code (version 1.97.2)
[✓] Connected device (5 available)
[✓] Network resources

Activity

  1. PrzemyslawPluszowy commented on Mar 5, 2025

    @PrzemyslawPluszowy

    this is bug. For now, my fix
    Open the function definition of showCupertinoSheet in Flutter's source code.
    2️⃣ Copy the implementation and create a custom version (e.g., myShowCupertinoSheet).
    3️⃣ Locate line 232 (or search for this entry):
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
    4️⃣Remove
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);

    5️⃣ Use myShowCupertinoSheet instead of the original function—problem solved!

  2. GiacomoPignoni commented on Mar 5, 2025

    @GiacomoPignoni
    Author

    @PrzemyslawPluszowy
    Your "fix" works only with the last iOS that is able to set the right status bar color based on what's back.
    There are 2 better workarounds that don't require to rewrite anything.

    • Put an AppBar in the previous page, the AppBar set the right SystemUiOverlayStyle based on the theme.

    or

    • Use what AppBar use to set the SystemUiOverlayStyle, that is AnnotatedRegion
    AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: child
    );
  3. darshankawar commented on Mar 6, 2025

    @darshankawar
    Member

    Thanks for the report. I was able to replicate the reported behavior on latest sdk versions.

    stable : 3.29.0
    master : 3.30.0-1.0.pre.467
    
  4. added
    platform-iosiOS applications specifically
    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
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 6, 2025
  5. changed the title [-][iOS] CupertinoPageRoute doesn't reset SystemUiOverlayStyle when closed[/-] [+][iOS] CupertinoSheetRoute doesn't reset SystemUiOverlayStyle when closed[/+] on Mar 6, 2025
  6. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Mar 12, 2025
  7. added a commit that references this issue on Apr 7, 2025
    b44137f
  8. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 8, 2025
  9. MitchellGoodwin commented on Apr 8, 2025

    @MitchellGoodwin
    Contributor

    Worth calling out: #164680 will not ensure that the system UI goes back to what it was when a Cupertino sheet is closed, it only removes overwriting the previous pages behavior. CupertinoSheetRoute does not reset the system UI because it can not know what to set the system UI to for the page behind it, it does not have that information. It is up to the previous page to set their system UI style. Which is how every route works in Flutter.

    As previously mentioned, a routes system UI is usually automatically set by a navbar, or any widget that adds AnnotatedRegion<SystemUiOverlayStyle> to the view. If that isn't present, you can add a AnnotatedRegion<SystemUiOverlayStyle> yourself. Or call SystemChrome.setSystemUIOverlayStyle when returning to the page. Both Navigator.of(context).push and showCupertinoSheet return a future, so SystemChrome.setSystemUIOverlayStyle can be called when that future resolves.

  10. github-actions commented on Apr 22, 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.

  11. locked as resolved and limited conversation to collaborators on Apr 22, 2025
  12. added a commit that references this issue on Jun 9, 2025
    6042152
  13. added a commit that references this issue on Aug 14, 2025
    f8a409c
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.30frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagesplatform-iosiOS applications specificallyr: 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