Repository navigation
[iOS] CupertinoSheetRoute doesn't reset SystemUiOverlayStyle when closed #164633
Copy link
Copy link
Closed
Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30Found to occur in 3.30frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagesplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
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 resourcesReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30Found to occur in 3.30frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagescupertino_ui package in flutter/packagesplatform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
PrzemyslawPluszowy commentedon Mar 5, 2025
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!
GiacomoPignoni commentedon Mar 5, 2025
@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.
AppBarin the previous page, theAppBarset the rightSystemUiOverlayStylebased on the theme.or
AppBaruse to set theSystemUiOverlayStyle, that isAnnotatedRegiondarshankawar commentedon Mar 6, 2025
Thanks for the report. I was able to replicate the reported behavior on latest sdk versions.
[-][iOS] CupertinoPageRoute doesn't reset SystemUiOverlayStyle when closed[/-][+][iOS] CupertinoSheetRoute doesn't reset SystemUiOverlayStyle when closed[/+]Fix: CupertinoSheetTransition moves SystemUIOverlayStyle to outside o…
MitchellGoodwin commentedon Apr 8, 2025
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 aAnnotatedRegion<SystemUiOverlayStyle>yourself. Or callSystemChrome.setSystemUIOverlayStylewhen returning to the page. BothNavigator.of(context).pushandshowCupertinoSheetreturn a future, soSystemChrome.setSystemUIOverlayStylecan be called when that future resolves.github-actions commentedon Apr 22, 2025
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 -vand a minimal reproduction of the issue.Fix: CupertinoSheetTransition moves SystemUIOverlayStyle to outside o…
Fix: CupertinoSheetTransition moves SystemUIOverlayStyle to outside o…