A Flutter plugin for monitoring process creation and termination events on Windows using FFI.
- Monitor all process start/stop events on Windows
- Monitor specific processes with per-process callbacks
- Control whether callbacks are triggered for each instance or only once
- Deduplication of duplicate events from the native layer
- Works in background isolate for non-blocking UI
Add to your pubspec.yaml:
dependencies:
process_monitor:
git:
url: https://github.com/yourusername/process_monitor.gitimport 'package:process_monitor/process_monitor.dart';final monitor = ProcessMonitor();
await monitor.startMonitoring();
monitor.processEvents.listen((event) {
print('Process ${event.processName} (${event.processId}) ${event.eventType} at ${event.timestamp}');
});final configs = [
ProcessConfig(
processName: 'notepad.exe',
onStart: (event) => print('Notepad started: ${event.processId}'),
onStop: (event) => print('Notepad stopped: ${event.processId}'),
allowMultipleStartCallbacks: true, // or false
allowMultipleStopCallbacks: true, // or false
),
];
await monitor.startMonitoringProcesses(configs);await monitor.stopMonitoring();Future<bool> startMonitoring()— Start monitoring all processesFuture<bool> startMonitoringProcesses(List<ProcessConfig>)— Monitor specific processes with callbacksStream<ProcessEvent> get processEvents— Stream of all process eventsFuture<bool> stopMonitoring()— Stop monitoringFuture<void> dispose()— Dispose and clean up resources
String processName— Name of the process to monitor (e.g. 'notepad.exe')void Function(ProcessEvent event)? onStart— Callback for process startvoid Function(ProcessEvent event)? onStop— Callback for process stopbool allowMultipleStartCallbacks— Call onStart for each instance?bool allowMultipleStopCallbacks— Call onStop for each instance?
String processName— Name of the processint processId— PIDString eventType— 'start' or 'stop'DateTime timestamp— Event time
See example/lib/main.dart for a full Flutter app example.
- Windows (FFI, WMI)
MIT