From f353cef1b0a0318b3c265dde4d3a2f12642b41b8 Mon Sep 17 00:00:00 2001 From: Jeff Mikels Date: Thu, 19 Aug 2021 13:01:34 -0400 Subject: [PATCH] null safe --- example/lib/main.dart | 46 +++++++++++++++++++++++-------------------- pubspec.yaml | 4 ++-- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index bf59225..7a36b9c 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -21,7 +21,7 @@ class _MyAppState extends State { initPlatformState() async { bool keptOn = await Screen.isKeptOn; double brightness = await Screen.brightness; - setState((){ + setState(() { _isKeptOn = keptOn; _brightness = brightness; }); @@ -33,26 +33,30 @@ class _MyAppState extends State { home: new Scaffold( appBar: new AppBar(title: new Text('Screen plugin example')), body: new Center( - child: new Column( - children: [ - new Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - new Text("Screen is kept on ? "), - new Checkbox(value: _isKeptOn, onChanged: (bool b){ - Screen.keepOn(b); - setState((){_isKeptOn = b; }); - }) - ] - ), - new Text("Brightness :"), - new Slider(value : _brightness, onChanged : (double b){ - setState((){_brightness = b;}); - Screen.setBrightness(b); - }) - ] - ) - ), + child: new Column(children: [ + new Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + new Text("Screen is kept on ? "), + new Checkbox( + value: _isKeptOn, + onChanged: (bool? b) { + if (b != null) { + Screen.keepOn(b); + setState(() { + _isKeptOn = b; + }); + } + }) + ]), + new Text("Brightness :"), + new Slider( + value: _brightness, + onChanged: (double b) { + setState(() { + _brightness = b; + }); + Screen.setBrightness(b); + }) + ])), ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index c3531d0..4d70bd2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: screen description: A Flutter plugin to manage the device's screen on Android and iOS. -version: 0.0.5 +version: 0.0.6 author: Clovis Nicolas homepage: https://github.com/clovisnicolas/flutter_screen environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: