windows_single_instance 1.0.1 copy "windows_single_instance: ^1.0.1" to clipboard
windows_single_instance: ^1.0.1 copied to clipboard

PlatformWindows

Forces a single instance of your Windows app, bringing the existing window to the front when a new instance is opened.

Windows Single Instance #

Restrict a Windows app to only be able to open one instance at a time.

Installing #

  1. Add WidgetsFlutterBinding.ensureInitialized(); to the start of your apps main function.
  2. Add the async modifier to your apps main function.
  3. Add a call to WindowsSingleInstance.ensureSingleInstance(), passing the apps startup args, a custom app string unique to your app (a-z, 0-9, _ and - only), and an optional callback function.

Example #

void main(List<String> args) async {
    WidgetsFlutterBinding.ensureInitialized();
    await WindowsSingleInstance.ensureSingleInstance(
        args,
        "custom_identifier",
        onSecondWindow: (args) {
            print(args);
        });
    runApp(const MyApp());
}
45
likes
140
points
7.55k
downloads

Publisher

verified publishersongbook-pro.com

Weekly Downloads

Forces a single instance of your Windows app, bringing the existing window to the front when a new instance is opened.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, win32

More

Packages that depend on windows_single_instance