screen_usage 0.0.1
screen_usage: ^0.0.1 copied to clipboard
Screen usage (screen on/off/unlocked) for iOS and Android
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:screen_usage/screen_usage.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
Screen _screenListener = new Screen();
ScreenEvent _screenEvent;
StreamSubscription<ScreenEvent> _screenEventSubscription;
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
_screenEventSubscription =
_screenListener.onScreenEvent.listen((ScreenEvent event) {
setState(() {
_screenEvent = event;
print("EVENT: $_screenEvent");
});
});
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Screen Usage App'),
),
body: new Center(),
),
);
}
}