Skip to content
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

migrate to null-safety #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 3.0.1
* Fix MissingPluginException for flutter web
* Thanks to https://github.com/rafaelmaeuer

## 3.0.0
* Added support for null safety
* Thanks to https://github.com/NarHakobyan

## 2.0.0
* Fix android X
* Fix iOS Dark mode styles
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# flutter_statusbar_manager

Now compatible with flutter web thanks to https://github.com/rafaelmaeuer
Now with support for null safety thanks to https://github.com/NarHakobyan
Now compatible with AndroidX thanks to https://github.com/lorenzOliveto

Flutter Statusbar Manager, lets you control the status bar color, style (theme), visibility, and translucent properties across iOS and Android. With some added bonus for Android to control the Navigation Bar.
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_statusbar_manager","path":"/Users/mendieta/Projects/flutter_statusbar_manager/","dependencies":[]}],"android":[{"name":"flutter_statusbar_manager","path":"/Users/mendieta/Projects/flutter_statusbar_manager/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_statusbar_manager","dependencies":[]}],"date_created":"2020-08-27 12:17:36.551472","version":"1.20.2"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_statusbar_manager","path":"/Users/rafael/Development/Public/flutter/flutter_statusbar_manager/","dependencies":[]}],"android":[{"name":"flutter_statusbar_manager","path":"/Users/rafael/Development/Public/flutter/flutter_statusbar_manager/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_statusbar_manager","dependencies":[]}],"date_created":"2021-06-04 22:29:15.118836","version":"2.2.1"}
62 changes: 34 additions & 28 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class MyApp extends StatefulWidget {
}

class _MyAppState extends State<MyApp> {
double _statusBarHeight = 0.0;
double? _statusBarHeight = 0.0;
bool _statusBarColorAnimated = false;
Color _statusBarColor = Colors.black;
Color? _statusBarColor = Colors.black;
double _statusBarOpacity = 1.0;
bool _statusBarHidden = false;
StatusBarAnimation _statusBarAnimation = StatusBarAnimation.NONE;
Expand All @@ -31,8 +31,8 @@ class _MyAppState extends State<MyApp> {
bool _fullscreenMode = false;

bool _navBarColorAnimated = false;
Color _navBarColor = Colors.black;
NavigationBarStyle _navBarStyle = NavigationBarStyle.DEFAULT;
Color? _navBarColor = Colors.black;
NavigationBarStyle? _navBarStyle = NavigationBarStyle.DEFAULT;

@override
void initState() {
Expand All @@ -42,7 +42,7 @@ class _MyAppState extends State<MyApp> {

// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
double statusBarHeight;
double? statusBarHeight;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
statusBarHeight = await FlutterStatusbarManager.getHeight;
Expand Down Expand Up @@ -70,7 +70,7 @@ class _MyAppState extends State<MyApp> {

void updateStatusBar() {
FlutterStatusbarManager.setColor(
_statusBarColor.withOpacity(_statusBarOpacity),
_statusBarColor!.withOpacity(_statusBarOpacity),
animated: _statusBarColorAnimated);
}

Expand All @@ -95,7 +95,7 @@ class _MyAppState extends State<MyApp> {
}

void updateNavBar() {
FlutterStatusbarManager.setNavigationBarColor(_navBarColor,
FlutterStatusbarManager.setNavigationBarColor(_navBarColor!,
animated: _navBarColorAnimated);
}

Expand Down Expand Up @@ -134,25 +134,25 @@ class _MyAppState extends State<MyApp> {
RadioListTile(
value: Colors.black,
title: Text("Black"),
onChanged: colorBarChanged,
onChanged: (Color? v) => colorBarChanged(v!),
dense: true,
groupValue: _statusBarColor),
RadioListTile(
value: Colors.orange,
title: Text("Orange"),
onChanged: colorBarChanged,
onChanged: (Color? v) => colorBarChanged(v!),
dense: true,
groupValue: _statusBarColor),
RadioListTile(
value: Colors.greenAccent,
title: Text("Green"),
onChanged: colorBarChanged,
onChanged: (Color? v) => colorBarChanged(v!),
dense: true,
groupValue: _statusBarColor),
RadioListTile(
value: Colors.white30,
title: Text("White"),
onChanged: colorBarChanged,
onChanged: (Color? v) => colorBarChanged(v!),
dense: true,
groupValue: _statusBarColor),
Text("Opacity:"),
Expand Down Expand Up @@ -184,39 +184,42 @@ class _MyAppState extends State<MyApp> {
RadioListTile(
value: StatusBarAnimation.NONE,
title: Text("NONE"),
onChanged: statusBarAnimationChanged,
onChanged: (StatusBarAnimation? v) =>
statusBarAnimationChanged(v!),
dense: true,
groupValue: _statusBarAnimation),
RadioListTile(
value: StatusBarAnimation.FADE,
title: Text("FADE"),
onChanged: statusBarAnimationChanged,
onChanged: (StatusBarAnimation? v) =>
statusBarAnimationChanged(v!),
dense: true,
groupValue: _statusBarAnimation),
RadioListTile(
value: StatusBarAnimation.SLIDE,
title: Text("SLIDE"),
onChanged: statusBarAnimationChanged,
onChanged: (StatusBarAnimation? v) =>
statusBarAnimationChanged(v!),
dense: true,
groupValue: _statusBarAnimation),
Divider(height: 25.0),
renderTitle("Status Bar Style:"),
RadioListTile(
value: StatusBarStyle.DEFAULT,
title: Text("DEFAULT"),
onChanged: statusBarStyleChanged,
onChanged: (StatusBarStyle? v) => statusBarStyleChanged(v!),
dense: true,
groupValue: _statusBarStyle),
RadioListTile(
value: StatusBarStyle.LIGHT_CONTENT,
title: Text("LIGHT_CONTENT"),
onChanged: statusBarStyleChanged,
onChanged: (StatusBarStyle? v) => statusBarStyleChanged(v!),
dense: true,
groupValue: _statusBarStyle),
RadioListTile(
value: StatusBarStyle.DARK_CONTENT,
title: Text("DARK_CONTENT"),
onChanged: statusBarStyleChanged,
onChanged: (StatusBarStyle? v) => statusBarStyleChanged(v!),
dense: true,
groupValue: _statusBarStyle),
Divider(height: 25.0),
Expand All @@ -228,8 +231,8 @@ class _MyAppState extends State<MyApp> {
this.setState(() {
_statusBarTranslucent = val;
});
FlutterStatusbarManager
.setTranslucent(_statusBarTranslucent);
FlutterStatusbarManager.setTranslucent(
_statusBarTranslucent);
},
),
Divider(height: 25.0),
Expand All @@ -241,8 +244,8 @@ class _MyAppState extends State<MyApp> {
this.setState(() {
_loadingIndicator = val;
});
FlutterStatusbarManager
.setNetworkActivityIndicatorVisible(_loadingIndicator);
FlutterStatusbarManager.setNetworkActivityIndicatorVisible(
_loadingIndicator);
},
),
Divider(height: 25.0),
Expand All @@ -260,45 +263,48 @@ class _MyAppState extends State<MyApp> {
RadioListTile(
value: Colors.black,
title: Text("Black"),
onChanged: colorNavBarChanged,
onChanged: (Color? v) => colorNavBarChanged(v!),
dense: true,
groupValue: _navBarColor),
RadioListTile(
value: Colors.orange,
title: Text("Orange"),
onChanged: colorNavBarChanged,
onChanged: (Color? v) => colorNavBarChanged(v!),
dense: true,
groupValue: _navBarColor),
RadioListTile(
value: Colors.greenAccent,
title: Text("Green"),
onChanged: colorNavBarChanged,
onChanged: (Color? v) => colorNavBarChanged(v!),
dense: true,
groupValue: _navBarColor),
RadioListTile(
value: Colors.white12,
title: Text("white"),
onChanged: colorNavBarChanged,
onChanged: (Color? v) => colorNavBarChanged(v!),
dense: true,
groupValue: _navBarColor),
Divider(height: 25.0),
renderTitle("Navigation Bar Style:"),
RadioListTile(
value: NavigationBarStyle.DEFAULT,
title: Text("DEFAULT"),
onChanged: navigationBarStyleChanged,
onChanged: (NavigationBarStyle? v) =>
navigationBarStyleChanged(v!),
dense: true,
groupValue: _navBarStyle),
RadioListTile(
value: NavigationBarStyle.LIGHT,
title: Text("LIGHT"),
onChanged: navigationBarStyleChanged,
onChanged: (NavigationBarStyle? v) =>
navigationBarStyleChanged(v!),
dense: true,
groupValue: _navBarStyle),
RadioListTile(
value: NavigationBarStyle.DARK,
title: Text("DARK"),
onChanged: navigationBarStyleChanged,
onChanged: (NavigationBarStyle? v) =>
navigationBarStyleChanged(v!),
dense: true,
groupValue: _navBarStyle),
Divider(height: 25.0),
Expand Down
6 changes: 4 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: flutter_statusbar_manager_example
description: Demonstrates how to use the flutter_statusbar_manager plugin.

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
cupertino_icons: ^1.0.3

dev_dependencies:
flutter_test:
Expand All @@ -21,7 +24,6 @@ dev_dependencies:

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down
16 changes: 10 additions & 6 deletions lib/flutter_statusbar_manager.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/foundation.dart' show kIsWeb;

enum StatusBarStyle { DEFAULT, LIGHT_CONTENT, DARK_CONTENT }

Expand All @@ -17,8 +18,6 @@ class _StatusBarStyle {
return DARK_CONTENT;
case StatusBarStyle.LIGHT_CONTENT:
return LIGHT_CONTENT;
default:
return DEFAULT;
}
}
}
Expand All @@ -38,8 +37,6 @@ class _StatusBarAnimation {
return FADE;
case StatusBarAnimation.SLIDE:
return SLIDE;
default:
return NONE;
}
}
}
Expand All @@ -59,8 +56,6 @@ class _NavigationBarStyle {
return DARK;
case NavigationBarStyle.LIGHT:
return LIGHT;
default:
return DEFAULT;
}
}
}
Expand All @@ -70,49 +65,58 @@ class FlutterStatusbarManager {
const MethodChannel('flutter_statusbar_manager');

static Future<bool> setColor(Color color, {bool animated = false}) async {
if (kIsWeb) return false;
return await _channel
.invokeMethod("setColor", {'color': color.value, 'animated': animated});
}

static Future<bool> setTranslucent(bool translucent) async {
if (kIsWeb) return false;
return await _channel
.invokeMethod("setTranslucent", {'translucent': translucent});
}

static Future<bool> setHidden(bool hidden,
{StatusBarAnimation animation = StatusBarAnimation.NONE}) async {
if (kIsWeb) return false;
return await _channel.invokeMethod("setHidden", {
'hidden': hidden,
'animation': _StatusBarAnimation.getAnimation(animation)
});
}

static Future<bool> setStyle(StatusBarStyle style) async {
if (kIsWeb) return false;
return await _channel
.invokeMethod("setStyle", {'style': _StatusBarStyle.getStyle(style)});
}

static Future<bool> setNetworkActivityIndicatorVisible(bool visible) async {
if (kIsWeb) return false;
return await _channel.invokeMethod(
"setNetworkActivityIndicatorVisible", {'visible': visible});
}

static Future<bool> setNavigationBarColor(Color color,
{bool animated = false}) async {
if (kIsWeb) return false;
return await _channel.invokeMethod(
"setNavigationBarColor", {'color': color.value, 'animated': animated});
}

static Future<bool> setNavigationBarStyle(NavigationBarStyle style) async {
if (kIsWeb) return false;
return await _channel.invokeMethod("setNavigationBarStyle",
{'style': _NavigationBarStyle.getStyle(style)});
}

static Future<double> get getHeight async {
if (kIsWeb) return 0.0;
return await _channel.invokeMethod("getHeight");
}

static setFullscreen(bool value) {
if (kIsWeb) return;
if (value) {
SystemChrome.setEnabledSystemUIOverlays([]);
} else {
Expand Down
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: flutter_statusbar_manager
description: Flutter Statusbar Manager, lets you control the status bar color, style (theme), visibility, and translucent properties across iOS and Android.
version: 2.0.0
version: 3.0.1
homepage: https://github.com/FooStudio/flutter_statusbar_manager

dependencies:
flutter:
sdk: flutter

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.12.0 <2.0.0"
sdk: ">=2.12.0 <3.0.0"

dev_dependencies:
flutter_test:
Expand Down