A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically.

Overview

flutter_statusbarcolor

pub package

A package can help you to change your flutter app's statusbar's color or navigationbar's color programmatically.

Getting Started

// change the status bar color to material color [green-400]
await FlutterStatusbarcolor.setStatusBarColor(Colors.green[400]);
if (useWhiteForeground(Colors.green[400])) {
  FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
} else {
  FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
}

// change the navigation bar color to material color [orange-200]
await FlutterStatusbarcolor.setNavigationBarColor(Colors.orange[200]);
if (useWhiteForeground(Colors.orange[200]) {
  FlutterStatusbarcolor.setNavigationBarWhiteForeground(true);
} else {
  FlutterStatusbarcolor.setNavigationBarWhiteForeground(false);
}

// get statusbar color and navigationbar color
Color statusbarColor = await FlutterStatusbarcolor.getStatusBarColor();
Color navigationbarColor = await FlutterStatusbarcolor.getNavigationBarColor();

preview

Details in example/ folder.

Api level minimum requirement

  • Android

    • getStatusBarColor (5.0)
    • setStatusBarColor (5.0)
    • setStatusBarWhiteForeground (6.0)
    • getNavigationBarColor (5.0)
    • setNavigationBarColor (5.0)
    • setNavigationBarWhiteForeground (8.0)
  • iOS

    • getStatusBarColor (7+)
    • setStatusBarColor (7+)
    • setStatusBarWhiteForeground (7+)

Note that

  • If you find the foreground brightness reverted after changing the app lifecycle, please use flutter's WidgetsBindingObserver mixin.
  • If iOS build does not work, please send issues or pull requests.
Comments
  • iOS 13 build failing

    iOS 13 build failing

    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.'

    opened by DavidDomkar 11
  • Open Dialog opacity change

    Open Dialog opacity change

    When setting the status bar and navigation bar colors the opacity when opening dialogs ignores the status bar and nav bars. Its expected that these would appear faded also. I have attached a screenshot of my result and one of the expected behavior. 1773519519

    Screenshot_20190709-003810

    opened by jfdeveloper92 8
  • FlutterStatusbarcolor.setStatusBarWhiteForeground(false) being automatically reverted to true moments after successfully being set false

    FlutterStatusbarcolor.setStatusBarWhiteForeground(false) being automatically reverted to true moments after successfully being set false

    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.

    opened by jonas-zebari 7
  • errors when building for android on flutter 0.11.3

    errors when building for android on flutter 0.11.3

    FAILURE: Build failed with an exception.

    • What went wrong: A problem occurred configuring project ':flutter_statusbarcolor'.

    Failed to notify project evaluation listener. java.lang.AbstractMethodError (no error message)

    opened by erwintan96 5
  • Errors when building for iOS

    Errors when building for iOS

    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.
    
    opened by bjornbjorn 5
  • Doesn't work on Android

    Doesn't work on Android

    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: https://github.com/mchome/flutter_statusbarcolor/pull/42

    How about merging it?

    opened by MarcusCambio 4
  • iOS build error : Property 'windowScene' not found on object of type 'UIWindow *'

    iOS build error : Property 'windowScene' not found on object of type 'UIWindow *'

    /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];
    
    duplicate 
    opened by azandrew-sidoine 3
  • Can't build release mode in android

    Can't build release mode in android

    • What went wrong:
      Execution failed for task ':app:lintVitalRelease'.

    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)

    opened by endigo 3
  • Black Foreground NOT working on ios 12.1

    Black Foreground NOT working on ios 12.1

    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: Screen Shot 2019-03-22 at 6 07 09 PM

    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)`

    help wanted 
    opened by magic-coding 3
  • Flutter 0.10 not compatible

    Flutter 0.10 not compatible

    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.
    
    
    bug 
    opened by wenerme 3
  • status bar foreground disappears when turning back from the desktop.

    status bar foreground disappears when turning back from the desktop.

    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.

    question 
    opened by blackredscarf 2
  • META: flutter_statusbarcolor vs AnnotatedRegion

    META: flutter_statusbarcolor vs AnnotatedRegion

    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!

    opened by lukepighetti 0
  • Add Flutter Module to a Native App

    Add Flutter Module to a Native App

    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.

    opened by rlecheta 0
  • FlutterStatusbarcolor.setStatusBarWhiteForeground(true); not working in ios 13 dark mode

    FlutterStatusbarcolor.setStatusBarWhiteForeground(true); not working in ios 13 dark mode

    status bar text still black.

    image

    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
    
    
    opened by jingjiewei 0
  • iOS `UIViewControllerBasedStatusBarAppearance = YES`

    iOS `UIViewControllerBasedStatusBarAppearance = YES`

    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

    opened by xiushaomin 0
  • color status bar disappears, when moving pages (Navigator)

    color status bar disappears, when moving pages (Navigator)

    color status bar disappears, when moving pages (Navigator), when the application starts image when the application moves page(navigator) image

    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);

    opened by rennaldy 1
It's a universal app template to have a great animated splash screen and liquid slider. Just change the animation if you want (rive) and change the images or colours according to your app.

liquid A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Zikyan Rasheed 28 Oct 7, 2022
ITS A SIMPLE CRYPTO APP THAT GIVES OR DISPLAYS PRICES - %CHANGE AND CHANGE VALUE OF TICKER (VARIOUS CRYPTO ASSERTS)

btcpricetracker A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

jatin upadhyay 0 Dec 28, 2021
Automatically generate profile picture with random first name and background color. But you can still provide pictures if you have them. As the default color, based on the name of the first letter. :fire: :fire: :fire:

FLUTTER PROFILE PICTURE Automatically generate profile picture with random first name and background color. But you can still provide pictures if you

Aditya Dharmawan Saputra 10 Dec 20, 2022
meg4cyberc4t 11 Oct 24, 2022
Material color picker, you can customize colors. Selection in two step, first main color and after shades.

Flutter Material Color Picker Material Color picker is a Flutter widget, that can be customizable. By default, it's Material Colors, but you can defin

Jean-Charles MoussΓ© 70 Nov 25, 2022
A package help you to make api call and handle error faster, also you can check for internet before call api.

http_solver ##not for production use, only for learning purpose. A package help you to make api call and handle error faster, also you can check for i

Abdelrahman Saed 1 Jun 18, 2020
null 0 Feb 2, 2022
An Instagram like text editor Flutter widget that helps you to change your text style.

TextEditor An instagram like text editor widget for flutter Show some ❀️ and star the repo to support the project Features Edit TextStyle object font

Mehdi Zarepour 68 Dec 16, 2022
ThemeX is an easy theme manipulation. Only inform primary color and the ThemeX generate all color combination palette for you

ThemeX is an easy theme manipulation basied on Material Design. Only inform primary color and the ThemeX generate all color combination palette for yo

Michael S. Lopes 2 Jan 31, 2022
A flutter list view which can drag & move item to change order.

draggable_flutter_list A flutter list view which can drag & move item to change order. some codes come from flutter_list_drag_and_drop fix flutter_lis

刘彦博 40 Sep 22, 2022
A flutter package which will help you to create a draggable widget that can be dragged around the screen.

A flutter package which will help you to create a draggable widget that can be dragged around the screen. Demo Features ?? Manually Control the positi

Adar 31 Aug 10, 2022
A Flutter add-to-app demo you can try with your own apps

Put Flutter to Work ?? Hello! This project is a demo intended to help people test drive Flutter by integrating it into their existing applications. In

Flutter 280 Jan 8, 2023
Flutter package that provides you custom clippers to help you achieve various custom shapes.

flutter_custom_clippers Flutter package that provides you custom clippers to help you achieve various custom shapes. Usage To use this plugin, add flu

Damodar Lohani 291 Dec 23, 2022
Flutter-Theme-Changer - Change theme of your app from light to dark theme and vice versa

Flutter Theme Changer - Hard Coded This is a flutter theme changer without using

Shametha K G 4 Oct 17, 2022
dos downloader app is developed for downloading video. You can download video from YouTube and Facebook. You can also play video on background

dosdownloader Dos downloader app is developed for downloading video. You can download video from YouTube and Facebook. You can also play video on back

Md Abir Ahsan Tahmim 1 Dec 8, 2021
Change App Package Name for Flutter

Change App Package Name for Flutter Change App Package Name with single command. It makes the process very easy and fast. What It does? Update Android

null 0 Dec 13, 2021
Z time ago - A simple Flutter z time ago package used to change date to time ago for english, arabic and kurdish languages

This package is used to get time duration from now and given time for kurdish, a

Zakarya Muhammad 2 May 19, 2022
Change App Package Name for Flutter

Change App Package Name with single command. It makes the process very easy and fast.

Atiq Samtia 94 Jan 7, 2023