flutter_statusbarcolor 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 93

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

Installation

Add this to your pubspec.yaml (or create it):

dependencies:
  flutter_statusbarcolor: any

Then run the flutter tooling:

flutter packages get

Example

// change the status bar color to material color [green-400].
try {
  await FlutterStatusbarcolor.setStatusBarColor(Colors.green[400]);
} on PlatformException catch (e) {
  print(e);
}

// change the navigation bar color to material color [orange-200].
try {
  await FlutterStatusbarcolor.setNavigationBarColor(Colors.orange[200]);
} on PlatformException catch (e) {
  print(e);
}

Details in example/ folder.

Note that

  • I dont have macos, so i cant test the ios part. If you can use it in ios or patch it, please let me know or send me a pr.

  • Android build api which below 21(Lollipop) does not work.

Changelog

[0.0.3]

  • Try to fix ios build again.

[0.0.2]

  • Try to fix ios build.

[0.0.1+1]

  • Format code.

[0.0.1]

  • Initial release.

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Color randomStatusColor = Colors.transparent;
  Color randomNavigationColor = Colors.transparent;

  changeStatusColor(Color color) async {
    try {
      await FlutterStatusbarcolor.setStatusBarColor(color);
    } on PlatformException catch (e) {
      print(e);
    }
  }

  changeNavigationColor(Color color) async {
    try {
      await FlutterStatusbarcolor.setNavigationBarColor(color);
    } on PlatformException catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            new Center(
              widthFactor: 1.5,
              child: new Column(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new Text('Set status bar color',
                    style: new TextStyle(fontSize: 20.0),),
                  new Divider(),
                  new FlatButton(
                    onPressed: () {
                      Color color = Colors.transparent;
                      changeStatusColor(color);
                    },
                    child: new Text('Transparent'),
                  ),
                  new Padding(padding: const EdgeInsets.all(10.0)),
                  new FlatButton(
                    onPressed: () {
                      Color color = Colors.amberAccent;
                      changeStatusColor(color);
                    },
                    child: new Text('amber-accent'),
                    color: Colors.amberAccent,
                  ),
                  new Padding(padding: const EdgeInsets.all(10.0)),
                  new FlatButton(
                    onPressed: () {
                      Color color = Colors.tealAccent;
                      changeStatusColor(color);
                    },
                    child: new Text('teal-accent'),
                    color: Colors.tealAccent,
                  ),
                  new Padding(padding: const EdgeInsets.all(10.0)),
                  new FlatButton(
                    onPressed: () {
                      Random rnd = new Random();
                      Color color = new Color.fromARGB(
                          rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256),
                          rnd.nextInt(256));
                      changeStatusColor(color);
                      setState(() => randomStatusColor = color);
                    },
                    child: new Text('Random color'),
                    color: randomStatusColor,
                  ),
                ],
              ),
            ),
            new Expanded(
              child: new Center(
                widthFactor: 1.5,
                child: new Column(
                  mainAxisSize: MainAxisSize.max,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    new Text('Set navigation bar color',
                      style: new TextStyle(fontSize: 20.0),),
                    new Divider(),
                    new FlatButton(
                      onPressed: () {
                        Color color = Colors.green[400];
                        changeNavigationColor(color);
                      },
                      child: new Text('Green-400'),
                      color: Colors.green[400],
                    ),
                    new Padding(padding: const EdgeInsets.all(10.0)),
                    new FlatButton(
                      onPressed: () {
                        Color color = Colors.lightBlue[100];
                        changeNavigationColor(color);
                      },
                      child: new Text('LightBlue-100'),
                      color: Colors.lightBlue[100],
                    ),
                    new Padding(padding: const EdgeInsets.all(10.0)),
                    new FlatButton(
                      onPressed: () {
                        Color color = Colors.cyanAccent[200];
                        changeNavigationColor(color);
                      },
                      child: new Text('CyanAccent-200'),
                      color: Colors.cyanAccent[200],
                    ),
                    new Padding(padding: const EdgeInsets.all(10.0)),
                    new FlatButton(
                      onPressed: () {
                        Random rnd = new Random();
                        Color color = new Color.fromARGB(
                            rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256),
                            rnd.nextInt(256));
                        setState(() => randomNavigationColor = color);
                        changeNavigationColor(color);
                      },
                      child: new Text('Random color'),
                      color: randomNavigationColor,
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_statusbarcolor: "^0.0.3"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
  
Version Uploaded Documentation Archive
0.0.3 Mar 15, 2018 Go to the documentation of flutter_statusbarcolor 0.0.3 Download flutter_statusbarcolor 0.0.3 archive
0.0.2 Mar 14, 2018 Go to the documentation of flutter_statusbarcolor 0.0.2 Download flutter_statusbarcolor 0.0.2 archive
0.0.1+1 Mar 11, 2018 Go to the documentation of flutter_statusbarcolor 0.0.1+1 Download flutter_statusbarcolor 0.0.1+1 archive
0.0.1 Feb 18, 2018 Go to the documentation of flutter_statusbarcolor 0.0.1 Download flutter_statusbarcolor 0.0.1 archive

Analysis

We analyzed this package on May 22, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.54.0
  • pana: 0.11.1
  • Flutter: 0.4.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
86 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
93
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.9
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7