windows_single_instance
1.2.0, released 5 months ago by songbook-pro.com
Restrict a Windows app to a single instance and bring existing windows to the front.
What it does
Forces a single instance of your Windows app, bringing the existing window to the front when a new instance is opened. It allows passing startup arguments and an optional callback when a second instance tries to launch.
AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to prevent users from opening multiple instances of your Windows desktop app
- You need to bring the existing application window to the foreground when a secondary launch is attempted
Skip it when
- Your application targets mobile, web, or non-Windows desktop platforms exclusively
- You want to allow multiple independent instances of your app to run simultaneously
Strengths
- Brings the correct window to the front even if it is minimized
- Supports passing custom arguments and exit functions to secondary instances
- Simple and straightforward setup in the main function
Weaknesses
- Platform-restricted to Windows
- Functionality is not supported on web even though it builds
Setup
- Kind
- Plugin (native code)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Add WidgetsFlutterBinding.ensureInitialized() and make main async, then call WindowsSingleInstance.ensureSingleInstance() with arguments and a unique custom app string.
void main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
await WindowsSingleInstance.ensureSingleInstance(
args,
"custom_identifier",
onSecondWindow: (args) {
print(args);
});
runApp(const MyApp());
}Alternatives
Packages that do the same job and could replace windows_single_instance.
- desktop_webview_window
Show a native webview window on your Flutter desktop application.
94Compare - fullscreen_window
A Flutter plugin to make your window fullscreen and get screen sizes.
53Compare - flutter_native_view
Embed native Windows windows and components directly into a Flutter window.
34Compare - multi_window
A package for adding multi window support to Flutter on Desktop.
47Compare
Works with
Packages commonly used together with windows_single_instance: ones it builds on, ones built on it, and its own family.