Skip to content

Commit

Permalink
migrate-null-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
NarHakobyan committed Mar 27, 2021
1 parent 305b790 commit a621002
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
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) {
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) {
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) {
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

0 comments on commit a621002

Please sign in to comment.