I'm a lazy copy-paste developer.
Don't trust the graph.
I don't code, I create bugs.
- β’β£β‘I don't like Javascript at all, and npm just sucks.
- I don't trust centralized services.
- Cantonese speaker.
- Loves isometric archviz.
- Dragon slayer.
A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically.
Home Page: https://pub.dev/packages/flutter_statusbarcolor
License: MIT License
I am facing a crash in my app because of a missing null condition in your plugin.
You have to add the below condition at the top of your plugin so that the headless check is done before the plugin is used.
Check the registerWith (and associated plugin constructor) for usage of registrar.activity(). Plugin's should first do a != null check before using it
For example, flutter_statusbarcolor is not checking if registrar.activity() != null before using it.
It should be doing this:
fun registerWith(registrar: Registrar): Unit {
val channel = MethodChannel(registrar.messenger(), "plugins.fuyumi.com/statusbar")
+ if (registrar.activity() != null) {
channel.setMethodCallHandler(FlutterStatusbarcolorPlugin(registrar.activity()))
+ }
}
Add the two lines marked with + in your plugin.
Status bar foreground disappears when turning back from the desktop in Android.
FlutterStatusbarcolor.setStatusBarColor(theme.scaffoldBackgroundColor);
FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
There is nothing in the status bar foreground.
status bar text still black.
flutter info:
[β] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.5 19F101, locale en-AU)
β’ Flutter version 1.17.4
β’ Framework revision 1ad9baa8b9 (6 days ago), 2020-06-17 14:41:16 -0700
β’ Engine revision ee76268252
β’ Dart version 2.8.4
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
β’ Android SDK at /Users/jason/Library/Android/sdk
β’ Platform android-29, build-tools 29.0.2
β’ ANDROID_HOME = /Users/jason/Library/Android/sdk
β’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
β’ All Android licenses accepted.
[β] Xcode - develop for iOS and macOS (Xcode 11.5)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 11.5, Build version 11E608c
β’ CocoaPods version 1.9.3
[!] Android Studio (version 3.5)
β’ Android Studio at /Applications/Android Studio.app/Contents
β Flutter plugin not installed; this adds Flutter specific functionality.
β Dart plugin not installed; this adds Dart specific functionality.
β’ Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[β] VS Code (version 1.46.1)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.11.0
It seems that there is a bug that is appearing with the introduction of iOS 13. When running on a phone rotated into landscape mode, a colored bar the size of the status bar in portrait mode is drawn on top of the app's content.
I'm using flutter v1.9.1+hotfix.4 and version 0.2.2 of the plugin.
To reproduce:
I set the navigation bar to white. It stays that way until I navigate back to the homepage then it turns black. Please help...
Could not resolve all artifacts for configuration ':app:dynamicProfileRuntimeClasspath'.
Could not resolve project :flutter_statusbarcolor.
Required by:
project :app
> java.lang.NullPointerException (no error message)
Hi, and thanks for this package! π
Just wanted to let you know that I tested the latest version (0.0.1+1) just now and got the following error when trying to build my project:
Launching lib/main.dart on iPhone 7 in debug mode...
Running Xcode clean...
Starting Xcode build...
Xcode build done
Failed to build iOS app
Error output from Xcode build:
β³
** BUILD FAILED **
Xcode's output:
β³
/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.0.1+1/ios/Classes/FlutterStatusbarcolorPlugin.m:18:33: error: invalid operands to binary expression ('NSNumber *' and 'int')
statusBar.backgroundColor = ANDROID_COLOR(color);
^~~~~~~~~~~~~~~~~~~~
/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.0.1+1/ios/Classes/FlutterStatusbarcolorPlugin.m:3:51: note: expanded from macro 'ANDROID_COLOR'
#define ANDROID_COLOR(c) [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:((c)&0xFF)/255.0 alpha:((c>>24)&0xFF)/255.0]
~^ ~~
1 error generated.
E/flutter ( 5392): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter ( 5392): MissingPluginException(No implementation found for method setstatusbarcolor on channel plugins.fuyumi.com/statusbar)
E/flutter ( 5392): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
E/flutter ( 5392):
E/flutter ( 5392): #1 FlutterStatusbarcolor.setStatusBarColor (package:flutter_statusbarcolor/flutter_statusbarcolor.dart:11:16)
should I change my android app name to com.fuyumi.flutterstatusbarcolor ?
How to use it inside completely new Flutter Project ?
best regards
http://alienryderflex.com/hsp.html
Current implementation tends to choose black in cases when white is much more appropriate.
/// Returns - a number in the rage of 0 (black) to 255 (white).
///
/// See **HSP Color Model**: http://alienryderflex.com/hsp.html
static int calcBrightness(Color color) {
var v = sqrt(pow(color.red, 2) * 0.299 + pow(color.green, 2) * 0.587 + pow(color.blue, 2) * 0.114);
int brightness = v.round();
return brightness;
}
static bool useWhiteForeground(Color color) {
// I selected cutoff value of 130 by trial and error and it reflects my taste,
// every value in the rage 128-145 will give acceptable results.
return calcBrightness(color) < 130 ? true : false;
}
Could not get this to work on Android, but then I saw that there is a PR that has been waiting to be merged for three weeks that did solve it: #42
How about merging it?
/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.2.2/ios/Classes/FlutterStatusbarcolorPlugin.m:71:105:
error: property 'windowScene' not found on object of type 'UIWindow *'
UIView* statusBar = [[UIView alloc]initWithFrame:[UIApplication
sharedApplication].keyWindow.windowScene.statusBarManager.statusBarFrame];
when use appBar in Scaffold widget , status bar icons color change
color status bar disappears, when moving pages (Navigator),
when the application starts
when the application moves page(navigator)
I put the code under the main.dart build material design widget
@override Widget build(BuildContext context) { FlutterStatusbarcolor.setNavigationBarColor(Colors.white); FlutterStatusbarcolor.setNavigationBarWhiteForeground(false); FlutterStatusbarcolor.setStatusBarColor(Colors.white); FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
I am testing this on a samsung s6.
Just adding the flutter_statusbarcolor: to the pubspec.yaml file makes the app impossible to run in the cellphone. (did not add any code, not even an import)
Weirdly, no error is given for me.
(Built build/app/outputs/apk/debug/app-debug.apk
then it tries to install and open it in cellphone, then it says "nameofapp" has stopped
issue also happens with simulator (nexus5 on API 26 Android 8.0)
If you need any further info, I'm happy to pass it...
It works fine on ios (tesing on an iphone6)
On iOS 13 there is a change in API which causes this error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
Hey! Just found this plugin, looks like a lot of people are enjoying it!
I was wondering if someone could help explain to me when you'd use this vs AnnotatedRegion to handle status bar color. Would be much appreciated, thank you!
Just installed this dependency and now my app is broken:
$ flutter run
Launching lib/main.dart on iPhone XΚ in debug mode...
Running Xcode build...
Xcode build done. 1,3s
Failed to build iOS app
Error output from Xcode build:
β³
** BUILD FAILED **
Xcode's output:
β³
note: Using new build systemnote: Planning buildnote: Constructing build descriptionerror: /Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find included file
'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')error:
/Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target
'Runner' from project 'Runner')error: /Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support
Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')error: /Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find
included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')error:
/Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target
'Runner' from project 'Runner')error: /Users/Bob/Documents/Projects/Flutter/myapp/ios/Flutter/Debug.xcconfig:1: could not find included file 'Pods/Target Support
Files/Pods-Runner/Pods-Runner.debug.xcconfig' in search paths (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone XΚ.
I removed this dependency and also cleared ~/.pub-cache/hosted/pub.dartlang.org/
directory but it didn't hepl, Flutter throws the same error, I can't restore my app now.
use deprecated API: setStatusBarStyle(_:animated:)
.However, some mature applications use settings such as UIViewControllerBasedStatusBarAppearance = YES, so setting setStatusBarWhiteForeground has no effectγhttps://developer.apple.com/documentation/uikit/uiapplication/1622923-setstatusbarstyle
Hey man!
I just want to report a problem in the current version you just released.
This current version 0.1.5
is a BREAKING version. It will not work on users using the previous one (0.1.4+1
) due to the androidx changes .
That said you should had given it a "plus one" to the middle version number making it to be 0.2.0
.
People usually uses the ^0.1.4
notation to import it into pub yaml. The ^0.1.X
notation will pull the latest version up to a ^0.2.X
.
You can read more about it here: https://www.dartlang.org/tools/pub/versioning
Best regards!
The project doesn't have unit tests and doesn't track the test coverage
Because setStatusBarColor
returns Future<dynamic>
instead of Future<void>
, I get _TypeError (type '() => void' is not a subtype of type '(dynamic) => FutureOr<dynamic>' of 'f')
when trying to use it in Future.wait with a couple of other futures.
status bar color ok
navigationbar not ok
in ios
The project doesn't have a builder that runs tests and build
You may use Travis or circleCI for this.
FAILURE: Build failed with an exception.
Failed to notify project evaluation listener.
java.lang.AbstractMethodError (no error message)
Any chance we can get a bit more explanation, for example what to the booleans like setNavigationBarWhiteForeground actually do? and why are they used?
When I change build.gradle
to use classpath 'com.android.tools.build:gradle:3.3.0'
I experience this error when running flutter run
:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.0 and higher.
The following dependencies do not satisfy the required version:
project ':flutter_statusbarcolor' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71
and probably need to downgrade to 3.2.1 as per https://stackoverflow.com/questions/54693595/flutter-the-android-gradle-plugin-supports-only-kotlin-gradle-plugin-version-1
Is it possible to upgrade?
Please add support for androidx.
Stacktrace :
Failed to build iOS app
Error output from Xcode build:
β³
** BUILD FAILED **
Xcode's output:
β³
/Users/me/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_sta
tusbarcolor-0.2.2/ios/Classes/FlutterStatusbarcolorPlugin.m:15:37: warning:
implicit conversion from 'long long' to 'NSInteger' (aka 'int') changes
value from 38482458385 to -172247279 [-Wconstant-conversion]
static NSInteger statusBarViewTag = 38482458385;
~~~~~~~~~~~~~~~~ ^~~~~~~~~~~
/Users/hugo/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_sta
tusbarcolor-0.2.2/ios/Classes/FlutterStatusbarcolorPlugin.m:71:105: error:
property 'windowScene' not found on object of type 'UIWindow *'
UIView* statusBar = [[UIView alloc]initWithFrame:[UIApplication
sharedApplication].keyWindow.windowScene.statusBarManager.statusB
arFrame];
^
1 warning and 1 error generated.
Flutter doctor, if needed :
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.13.6 17G65, locale
fr-FR)
[β] Android toolchain - develop for Android devices
β Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/setup/#android-setup for detailed
instructions).
If the Android SDK has been installed to a custom location, set
ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[β] Xcode - develop for iOS and macOS (Xcode 10.1)
[!] Android Studio (not installed)
[!] Connected device
! No devices available
! Doctor found issues in 3 categories.
Hi, I'm creating a flutter module to use in some native app, I'm following this guide:
https://flutter.dev/docs/development/add-to-app
But the flutter_statusbarcolor plugin doesn't work as a module because it was done with the old flutter plugin system and it should be migrated:
https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration
This is the error, after create a Flutter Module with the flutter_statusbarcolor:
The plugin flutter_statusbarcolor is built using an older version of the Android plugin API which assumes that it's running in a full-Flutter environment. It may have undefined behaviors when Flutter is integrated into an existing app as a module. The plugin can be updated to the v2 Android Plugin APIs by following https://flutter.dev/go/android-plugin-migration.
I think this is an easy fix, looking forward to see it, thank you.
/Users/christian/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.2.3/ios/Classes/FlutterStatusbarcolorPlugin.m:15:37: warning: implicit conversion from 'long long' to 'NSInteger' (aka 'int') changes value from 38482458385 to -172247279 [-Wconstant-conversion] static NSInteger statusBarViewTag = 38482458385;
How I use plugin in my code:
FlutterStatusbarcolor.setStatusBarColor(Theme.of(context).accentColor);
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale it-IT)[β] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[β] Xcode - develop for iOS and macOS (Xcode 11.3)
[β] Android Studio (version 3.5)
[!] VS Code (version 1.41.1)
β Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[β] Connected device (1 available)
Hi Everyone,
I am having an issue when the app starts the foreground colour of the bottom navigation is always dark.
I am using a dark themes app. If I then toggle my to light then dark it works as it should. Also, switching apps it works as desired.
The only issue is when the app first starts. I am using a Note 10.
I also used the code from the example app.
Regards
Main main method:
void main() {
FlutterStatusbarcolor.setNavigationBarColor(Colors.white);
FlutterStatusbarcolor.setNavigationBarWhiteForeground(false);
FlutterStatusbarcolor.setStatusBarColor(Colors.white);
FlutterStatusbarcolor.setStatusBarWhiteForeground(false); // automatically gets reverted even with empty project
runApp(Messages());
}
After hot restarting and/or full restarting, the color of the status bar icons goes from dark to light. I will provide any additional informationt that I can just let me know, thanks.
I have used this package as a test , this works fine , now i need to remove this package , i have deleted this from pubspec.yaml but now project is not building for ios , android builds fine but i am getting this error while building for ios
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with βUse of deprecated Swift 3 @objc inferenceβ logging enabled, and then disable inference by changing the "Swift 3 @objc Inference" build setting to "Default" for the "Runner" target.
=== BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
ld: warning: directory not found for option '-F/Users/diablo/Projects/flutter/test-flutter/build/ios/Debug-iphonesimulator/flutter_statusbarcolor'
ld: warning: directory not found for option '-F/Users/diablo/Projects/flutter/test-flutter/ios/Pods/../.symlinks/flutter/ios'
ld: framework not found flutter_statusbarcolor
clang: error: linker command failed with exit code 1 (use -v to see invocation)
any solution to this ? i have tried flutter clean
but it didnt work
I need to set a grey background for a status bar with black color for foreground but still not working.
The status bar background color chnaged to gery but the foreground still with white color.
output:
My code:
await FlutterStatusbarcolor.setStatusBarColor(Colors.grey[100]);
await FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
My flutter doctor:
`[β] Flutter (Channel stable, v1.2.1, on Mac OS X 10.14 18A391, locale en-US)
β’ Flutter version 1.2.1 at /Users/xx/flutter
β’ Framework revision 8661d8aecd (5 weeks ago), 2019-02-14 19:19:53 -0800
β’ Engine revision 3757390fa4
β’ Dart version 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
[β] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
β’ Android SDK at /Users/xx/Library/Android/sdk
β’ Android NDK location not configured (optional; useful for native profiling support)
β’ Platform android-28, build-tools 28.0.3
β’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
β’ Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
β’ All Android licenses accepted.
[β] iOS toolchain - develop for iOS devices (Xcode 10.1)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 10.1, Build version 10B61
β’ ios-deploy 1.9.4
β’ CocoaPods version 1.6.1
[β] Android Studio (version 3.2)
β’ Android Studio at /Applications/Android Studio.app/Contents
β’ Flutter plugin version 31.3.1
β’ Dart plugin version 181.5656
β’ Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[β] VS Code (version 1.32.3)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 2.24.0
[β] Connected device (2 available)
β’ iPhone 8 β’ ios β’ iOS 12.1.4
β’ iPhone 8 β’ ios β’ iOS 12.1 (simulator)`
Starting Xcode build...
Xcode build done. 1.7s
Failed to build iOS app
Error output from Xcode build:
β³
** BUILD FAILED **
Xcode's output:
β³
/Users/wener/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.1.0/ios/Classes/FlutterStatusbarcolorPlugin.m:18:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'NSNumber *' [-Wint-conversion]
int colors = @([color intValue]);
^ ~~~~~~~~~~~~~~~~~~~
/Users/wener/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.1.0/ios/Classes/FlutterStatusbarcolorPlugin.m:24:30: error: use of undeclared identifier 'usewhiteforeground'
NSNumber numberWithBool:*usewhiteforeground = call.arguments[@"whiteForeground"];
^
/Users/wener/.pub-cache/hosted/pub.dartlang.org/flutter_statusbarcolor-0.1.0/ios/Classes/FlutterStatusbarcolorPlugin.m:25:9: error: use of undeclared identifier 'usewhiteforeground'
if (usewhiteforeground) {
^
1 warning and 2 errors generated.
Could not build the application for the simulator.
Error launching application on iPhone 8.
Doctor summary (to see all details, run flutter doctor -v):
[β] Flutter (Channel dev, v0.10.0, on Mac OS X 10.13.6 17G2307, locale en-CN)
[β] Android toolchain - develop for Android devices
β Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
You may also want to add it to your PATH environment variable.
[β] iOS toolchain - develop for iOS devices (Xcode 10.0)
[β] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2018.2.2)
β Flutter plugin not installed; this adds Flutter specific functionality.
β Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.28.0)
[β] Connected device (1 available)
! Doctor found issues in 3 categories.
Can we have an option to get the statusbar color? This is useful when wanting to save the old value so we can restore it later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.