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 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 3 additions & 3 deletions lib/flutter_statusbar_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class _StatusBarStyle {
static const String LIGHT_CONTENT = "light-content";
static const String DARK_CONTENT = "dark-content";

static String getStyle(StatusBarStyle style) {
static String getStyle(StatusBarStyle? style) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not accept null values here

switch (style) {
case StatusBarStyle.DEFAULT:
return DEFAULT;
Expand All @@ -30,7 +30,7 @@ class _StatusBarAnimation {
static const String FADE = "fade";
static const String SLIDE = "slide";

static String getAnimation(StatusBarAnimation animation) {
static String getAnimation(StatusBarAnimation? animation) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

switch (animation) {
case StatusBarAnimation.NONE:
return NONE;
Expand All @@ -51,7 +51,7 @@ class _NavigationBarStyle {
static const String DARK = "light";
static const String LIGHT = "dark";

static String getStyle(NavigationBarStyle style) {
static String getStyle(NavigationBarStyle? style) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

switch (style) {
case NavigationBarStyle.DEFAULT:
return DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
sdk: flutter

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

dev_dependencies:
Expand Down