Search packages, repositories and app categories

Package detailsv1.2.0

windows_single_instance

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

Windows
30-day downloads
22.1K
Likes
54
Pub points
150

Install package

flutter pub add windows_single_instance

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The windows_single_instance package ensures that only one instance of a Flutter app runs on Windows at a time. When a second instance is launched, it detects the existing process and brings the original window to the front instead of creating a new one. This behavior improves user experience by preventing duplicate app windows and maintaining focus on the active instance. The package integrates seamlessly with Flutter’s desktop platform and requires no additional configuration beyond adding the dependency.

Use cases

  • Preventing duplicate app windows
  • Improving user workflow on Windows
  • Ensuring single active instance
  • Handling app launch from shortcuts
  • Managing background processes

Key features

  • Automatic window focus on re-launch
  • Cross-process detection
  • Minimal setup
  • Windows-only support
  • No external dependencies

Suitable for

  • Desktop Windows apps
  • Single-window applications
  • User-facing utilities
  • Tools requiring focused interaction
  • Apps with persistent state

Considerations

  • Limited to Windows platform
  • Requires proper initialization
  • May conflict with other single-instance solutions
  • Not applicable for multi-instance workflows
  • Does not handle app shutdown gracefully

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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());
}

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package