Closed fifabell closed 3 years ago
in pubspec.yaml dependencies: flutter: sdk: flutter screen: ^0.0.5
in androidManifest
copy to Paste in my code. https://pub.dev/packages/screen/example
import 'package:flutter/material.dart'; import 'package:screen/screen.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); }
class _MyAppState extends State { bool _isKeptOn = false; double _brightness = 1.0;
@override initState() { super.initState(); initPlatformState(); }
initPlatformState() async { bool keptOn = await Screen.isKeptOn; double brightness = await Screen.brightness; setState(() { _isKeptOn = keptOn; _brightness = brightness; }); }
@override Widget build(BuildContext context) { return new MaterialApp( 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); }) ])), ), ); } }
Error: MissingPluginException(No implementation found for method setBrightness on channel github.com/clovisnicolas/flutterscreen) at Object.throw [as throw] (http://localhost:54117/dart_sdk.js:5334:11) at MethodChannel._invokeMethod (http://localhost:54117/packages/flutter/src/services/system_channels.dart.lib.js:954:21) at _invokeMethod.next () at http://localhost:54117/dart_sdk.js:39032:33 at _RootZone.runUnary (http://localhost:54117/dart_sdk.js:38889:58) at _FutureListener.thenAwait.handleValue (http://localhost:54117/dart_sdk.js:33875:29) at handleValueCallback (http://localhost:54117/dart_sdk.js:34435:49) at Function._propagateToListeners (http://localhost:54117/dart_sdk.js:34473:17) at _Future.new.[_completeWithValue] (http://localhost:54117/dart_sdk.js:34315:23) at async._AsyncCallbackEntry.new.callback (http://localhost:54117/dart_sdk.js:34338:35) at Object._microtaskLoop (http://localhost:54117/dart_sdk.js:39176:13) at _startMicrotaskLoop (http://localhost:54117/dart_sdk.js:39182:13) at http://localhost:54117/dart_sdk.js:34689:9
I used flutter 2.0.1 (stable), I tried to "flutter clean".
sorry, I tried to Chrome .....T.T, It works well on Android.
I was ,
in pubspec.yaml dependencies: flutter: sdk: flutter screen: ^0.0.5
in androidManifest
copy to Paste in my code. https://pub.dev/packages/screen/example
import 'package:flutter/material.dart'; import 'package:screen/screen.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget { @override _MyAppState createState() => new _MyAppState(); }
class _MyAppState extends State {
bool _isKeptOn = false;
double _brightness = 1.0;
@override initState() { super.initState(); initPlatformState(); }
initPlatformState() async { bool keptOn = await Screen.isKeptOn; double brightness = await Screen.brightness; setState(() { _isKeptOn = keptOn; _brightness = brightness; }); }
@override Widget build(BuildContext context) { return new MaterialApp( 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);
})
])),
),
);
}
}
Successful hot load.... but, When I setState, I met the "MissingPluginException"
Error: MissingPluginException(No implementation found for method setBrightness on channel github.com/clovisnicolas/flutterscreen) at Object.throw [as throw] (http://localhost:54117/dart_sdk.js:5334:11) at MethodChannel._invokeMethod (http://localhost:54117/packages/flutter/src/services/system_channels.dart.lib.js:954:21) at _invokeMethod.next ()
at http://localhost:54117/dart_sdk.js:39032:33
at _RootZone.runUnary (http://localhost:54117/dart_sdk.js:38889:58)
at _FutureListener.thenAwait.handleValue (http://localhost:54117/dart_sdk.js:33875:29)
at handleValueCallback (http://localhost:54117/dart_sdk.js:34435:49)
at Function._propagateToListeners (http://localhost:54117/dart_sdk.js:34473:17)
at _Future.new.[_completeWithValue] (http://localhost:54117/dart_sdk.js:34315:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:54117/dart_sdk.js:34338:35)
at Object._microtaskLoop (http://localhost:54117/dart_sdk.js:39176:13)
at _startMicrotaskLoop (http://localhost:54117/dart_sdk.js:39182:13)
at http://localhost:54117/dart_sdk.js:34689:9
I used flutter 2.0.1 (stable), I tried to "flutter clean".