New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flutter not automatically changing the status bar icons to black on devices running iOS 13.0 in Dark Mode it only does so when Dark Mode on iOS 13 is turned off #41067
Comments
Turn off dark mode on your device and it will appear as before. Yet I don't know how to adapt if dark mode is on. |
@Mugen0 Thanks I actually lost my temper with it and yet such a simple fix |
@Mugen0 maybe you can open an issue for the Dark Mode. |
Turning off dark mode on iOS 13 is not the solution. We should have a way to either detect dark mode and deal with the status bar color by ourselves or the framework could do it automatically. It should be an issue to be fixed. |
Some time ago I've written a simple plugin for getting iOS 13 Dark Mode enabled state |
@vanelizarov could you please illustrate a comprehensive example on how to use your plugin? |
@vanelizarov I got an error with the plugin. |
@Mugen0 your app needs to be scaffolded with Swift language because plugin is written in Swift |
@Chimba123 sorry for the false alarm, I've tried to write an example app and figured out that my plugin can help, but not exactly in the way I've expected. For example you can subscribe to import 'package:flutter/cupertino.dart';
import 'package:flutter_ios_dark_mode/flutter_ios_dark_mode.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamBuilder<bool>(
stream: FlutterIosDarkMode().onDarkModeStateChanged,
initialData: false,
builder: (context, snapshot) {
return CupertinoApp(
debugShowCheckedModeBanner: false,
theme: CupertinoThemeData(
brightness: snapshot.data ? Brightness.dark : Brightness.light,
),
home: Home(),
);
},
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(),
child: Container(),
);
}
} Unfortunately, if you set |
|
Any news on this ? |
FlutterPlatformPlugin- (void)setSystemChromeSystemUIOverlayStyle:(NSDictionary*)message {
NSString* style = message[@"statusBarBrightness"];
if (style == (id)[NSNull null])
return;
UIStatusBarStyle statusBarStyle;
if ([style isEqualToString:@"Brightness.dark"])
statusBarStyle = UIStatusBarStyleLightContent;
else if ([style isEqualToString:@"Brightness.light"])
statusBarStyle = UIStatusBarStyleDefault;
else
return;
NSNumber* infoValue = [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"];
Boolean delegateToViewController = (infoValue == nil || [infoValue boolValue]);
if (delegateToViewController) {
// This notification is respected by the iOS embedder
[[NSNotificationCenter defaultCenter]
postNotificationName:@(kOverlayStyleUpdateNotificationName)
object:nil
userInfo:@{@(kOverlayStyleUpdateNotificationKey) : @(statusBarStyle)}];
} else {
// Note: -[UIApplication setStatusBarStyle] is deprecated in iOS9
// in favor of delegating to the view controller
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle];
}
} engine code ,we can see no UIStatusBarStyleDarkContent delete ‘UIViewControllerBasedStatusBarAppearance ’ from info.plist add notification [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appStatusBar:) name:@"io.flutter.plugin.platform.SystemChromeOverlayNotificationName" object:nil];
- (void)appStatusBar:(id)notification {
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
}
} |
The problem is I sent flutter/engine#13119 to use |
@jayjun keep us posted |
@blackox626 thanks for the idea, I've finally figured out how to temporarily fix this issue via native code, while we all are waiting for @jayjun's PR to be merged
let kOverlayStyleUpdateNotificationName = "io.flutter.plugin.platform.SystemChromeOverlayNotificationName"
let kOverlayStyleUpdateNotificationKey = "io.flutter.plugin.platform.SystemChromeOverlayNotificationKey"
extension FlutterViewController {
private struct StatusBarStyleHolder {
static var style: UIStatusBarStyle = .default
}
open override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(
self,
selector: #selector(appStatusBar(notification:)),
name: NSNotification.Name(kOverlayStyleUpdateNotificationName),
object: nil
)
}
open override var preferredStatusBarStyle: UIStatusBarStyle {
return StatusBarStyleHolder.style
}
@objc private func appStatusBar(notification: NSNotification) {
guard
let info = notification.userInfo as? Dictionary<String, Any>,
let statusBarStyleKey = info[kOverlayStyleUpdateNotificationKey] as? Int
else {
return
}
if #available(iOS 13.0, *) {
StatusBarStyleHolder.style = statusBarStyleKey == 0 ? .darkContent : .lightContent
} else {
StatusBarStyleHolder.style = statusBarStyleKey == 0 ? .default : .lightContent
}
setNeedsStatusBarAppearanceUpdate()
}
} |
Same. Still waiting for fix. |
Hm, almost 4 months of waiting.. |
This solves the status bar color problem, but results in another. |
Add line in Info.plist <key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/> And change status bar 👍 import 'package:flutter/services.dart';
/// ...
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarBrightness: Brightness.light) // Or Brightness.dark
); |
nice!!! |
Thank you! For beginners like me: |
One more possible workaround:
|
@330676687 Works like a charm. Tks! |
Seems to be working on master now. Closing. |
Will a hotfix be issued on 1.12.13 for this fix? Or this won’t be merged to stable until next major release? |
@edwardez not that I know of. To quote the wiki:
Switching to the dev channel or the beta channel could also be an option. |
Make sense, I was thinking this issue has lots of votes and might be merged to stable as an exception...thanks for the detailed explanation. |
Fixed by flutter/engine#13119 |
@mono0926 is it safe for us to use the Master Channel in production? Our concern is a production ready solution, not a developer-only solution. |
@mono0926 if we can't use the master channel to deploy our final Apps to the App store as a well-finished product then I'd advise you to re-open the issue till it is properly addressed on the stable channel |
It works fine in the simulator, but on a real device it doesn't work... |
My app freezes when I run Flutter from master channel. I had to switch to stable version where's no fix exists for this issue. News, guys? |
btw: @eugene-kalaganov It's a bad practice to fully rely on how things work in a simulator (iOS). |
How can we have this fix in our apps? |
@atereshkov could you create a new issue, if there isn't one already? That sounds like a severe problem. also the dev channel and the beta channel should have the fix now if you don't want to patch and build the engine manually. |
@atereshkov are there any news about this issue? Could you create a new issue? |
@ilweonair I'll check it one more time today and will address if it's still an issue |
For me this issue is fixed in |
Obviously, I think that it isn’t possible to work with a beta version in a
production environment
Il giorno mar 25 feb 2020 alle 07:19 Nils Reichardt <
notifications@github.com> ha scritto:
… For me this issue is fixed in flutter beta and everything is working fine
👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#41067?email_source=notifications&email_token=ABBDWNJDN4OEGLPT22EC5ELRESZ67A5CNFSM4IZE7OZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM2WY2Y#issuecomment-590703723>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBDWNLSMF6EWCSN5ZJVICDRESZ67ANCNFSM4IZE7OZA>
.
|
@ilweonair Depends on your pipelining needs. We typically deploy from |
work like charm <3 |
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 |
I upgraded my iPhone X operating system(OS) from 12.4 to iOS 13.0 and I also updated my Xcode to version 11. I have noticed one puzzling thing, previously when loading my Flutter app on my iPhone X running iOS 12.4 then the status bar icons(network, wifi, battery, time) would automatically turn black to provide contrast from the grey
Cupertino Navigation Bar
and whiteMaterial App Bar
widgets. But when I upgraded the OS on the actual device this automatic functionality is gone and the status icons are white and barely visible. It only does so when Dark Mode on the device is turned off.How could we get the automatic functionality of status bar icons and text switching to black in Dark Mode on iOS 13?
The text was updated successfully, but these errors were encountered: