screen_usage 0.0.4 copy "screen_usage: ^0.0.4" to clipboard
screen_usage: ^0.0.4 copied to clipboard

A plugin for reporting screen events while the flutter application is running in background. Works for Android only.

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 _screen = new Screen();
  StreamSubscription<ScreenEvent> _subscription;

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

  Future<void> initPlatformState() async {
    _subscription = _screen.screenEvents.listen(_onData, onError: _onError, onDone: _onDone, cancelOnError: true);
  }

  void _onData(ScreenEvent event) async {
    print(event);
  }

  void _onDone() {}

  void _onError(error) {
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Screen Usage App'),
        ),
        body: new Center(),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

verified publishercachet.dk

A plugin for reporting screen events while the flutter application is running in background. Works for Android only.

Homepage
Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_usage