flutter_system_events 1.1.0 copy "flutter_system_events: ^1.1.0" to clipboard
flutter_system_events: ^1.1.0 copied to clipboard

A Flutter plugin for listening to keyboard, lifecycle, network, memory, battery, orientation, time, screen, screenshot, and thermal events.

example/lib/main.dart

import 'dart:async';

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

import 'system_events_example_app.dart';

void main() => runApp(const SystemEventsExample());

class SystemEventsExample extends StatefulWidget {
  const SystemEventsExample({super.key});

  @override
  State<SystemEventsExample> createState() => _SystemEventsExampleState();
}

class _SystemEventsExampleState extends State<SystemEventsExample> {
  StreamSubscription<ScreenshotEvent>? _screenshotSubscription;
  StreamSubscription<ThermalEvent>? _thermalSubscription;

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

    unawaited(SystemEvents.initialize(config: const SystemEventsConfig.all()));

    _screenshotSubscription = SystemEvents.screenshot.listen((event) {
      debugPrint('screenshot taken');
    });

    _thermalSubscription = SystemEvents.thermal.listen((event) {
      debugPrint('thermal state=${event.state.name}');
    });
  }

  @override
  void dispose() {
    unawaited(_screenshotSubscription?.cancel());
    unawaited(_thermalSubscription?.cancel());
    unawaited(SystemEvents.dispose());
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const SystemEventsExampleApp();
  }
}
1
likes
160
points
630
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for listening to keyboard, lifecycle, network, memory, battery, orientation, time, screen, screenshot, and thermal events.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on flutter_system_events

Packages that implement flutter_system_events