screen_plugin 0.0.3 copy "screen_plugin: ^0.0.3" to clipboard
screen_plugin: ^0.0.3 copied to clipboard

screen_plugin.

example/lib/main.dart

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

import 'package:screen_plugin/screen_controller.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  Future<void> initPlatformState() async {
    ScreenController.registerReceiver();
    ScreenController.statusChangedListener((open){
      print("=================${open.toString()}=================");
    }, (t){});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RaisedButton(
            onPressed: (){
              _onPressed();
            },
            child: Text(
              "获取",
            ),
          ),
        ),
      ),
    );
  }

  _onPressed() async{
    bool isScreenOn = await ScreenController.isScreenOn();
    print("=================${isScreenOn.toString()}=================");
  }

}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

screen_plugin.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_plugin