screen_state 0.0.5 copy "screen_state: ^0.0.5" to clipboard
screen_state: ^0.0.5 copied to clipboard

outdated

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_state/screen_state.dart';

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

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

class _MyAppState extends State<MyApp> {
  Screen _screen;
  StreamSubscription<ScreenStateEvent> _subscription;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    startListening();
  }

  void onData(ScreenStateEvent event) {
    print(event);
  }

  void startListening() {
    _screen = new Screen();
    try {
      _subscription = _screen.screenStateStream.listen(onData);
    } on ScreenStateException catch (exception) {
      print(exception);
    }
  }

  void stopListening() {
    _subscription.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Screen State Example app'),
        ),
        body: new Center(),
      ),
    );
  }
}
35
likes
0
pub points
91%
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

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_state