flutter_system_events 0.5.0
flutter_system_events: ^0.5.0 copied to clipboard
A Flutter plugin for listening to keyboard, lifecycle, network, memory, battery, and orientation events on Android and iOS.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'pages/battery_event_page.dart';
import 'pages/keyboard_event_page.dart';
import 'pages/lifecycle_event_page.dart';
import 'pages/memory_event_page.dart';
import 'pages/network_event_page.dart';
import 'pages/orientation_event_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: EventListPage());
}
}
class EventListPage extends StatelessWidget {
const EventListPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('System Events')),
body: ListView(
children: [
ListTile(
title: const Text('Keyboard'),
subtitle: const Text('Show, hide, height'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const KeyboardEventPage(),
),
);
},
),
ListTile(
title: const Text('Lifecycle'),
subtitle: const Text('Resume, inactive, pause, detach'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const LifecycleEventPage(),
),
);
},
),
ListTile(
title: const Text('Network'),
subtitle: const Text('Online, offline, type'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const NetworkEventPage(),
),
);
},
),
ListTile(
title: const Text('Memory'),
subtitle: const Text('Warning, low memory, trim'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const MemoryEventPage(),
),
);
},
),
ListTile(
title: const Text('Battery'),
subtitle: const Text('Level, charging, state'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const BatteryEventPage(),
),
);
},
),
ListTile(
title: const Text('Orientation'),
subtitle: const Text('Portrait, landscape, direction'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const OrientationEventPage(),
),
);
},
),
],
),
);
}
}