zyh_screen 0.0.1 copy "zyh_screen: ^0.0.1" to clipboard
zyh_screen: ^0.0.1 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:zyh_screen/zyh_screen.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isKeptOn = false;
  double _brightness = 1.0;

  @override
  initState() {
    super.initState();
    initPlatformState();
  }

  initPlatformState() async {
    bool keptOn = await ZyhScreen.isKeptOn;
    double brightness = await ZyhScreen.brightness;
    print("Brightness:========" + brightness.toString());
    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: <Widget>[
                  new Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        new Text("Screen is kept on ? "),
                        new Checkbox(value: _isKeptOn, onChanged: (bool b){
                          ZyhScreen.keepOn(b);
                          setState((){_isKeptOn = b; });
                        })
                      ]
                  ),
                  new Text("Brightness :"),
                  new Slider(value : _brightness, onChanged : (double b){
                    setState((){_brightness = b;});
                    ZyhScreen.setBrightness(b);
                  })
                ]
            )
        ),
      ),
    );
  }
}
0
likes
25
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on zyh_screen