multi_instance_handler library

Detects and handles multiple instances of an application. This library allows you to forward command line arguments from second instances of an application, force a single instance of an application, or both.

Functions

isFirstInstance([List<String>? args]) Future<bool>
Returns whether the current process is the only instance of the app running. If it returns false, another process is already running; the command line arguments passed in as args will be forwarded to the previous instance to be processed by the onSecondInstance() callback.
onSecondInstance(dynamic cb(List<String>)) → void
Attaches a callback to be run whenever a second instance of the app is executed. The arguments from that second instance will be passed into the callback.