Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/SongbookPro/flutter_windows_single_instance
https://github.com/SongbookPro/flutter_windows_single_instance
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/SongbookPro/flutter_windows_single_instance
- Owner: SongbookPro
- License: mit
- Created: 2022-04-01T21:17:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-17T14:29:48.000Z (about 1 year ago)
- Last Synced: 2024-08-03T19:09:19.856Z (5 months ago)
- Language: C++
- Size: 90.8 KB
- Stars: 10
- Watchers: 1
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flutter-desktop - windows_single_instance - Forces a single instance of your Windows app, bringing the existing window to the front when a new instance is opened. (Packages)
README
# 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.
1. Add the `async` modifier to your apps `main` function.
1. 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 args) async {
WidgetsFlutterBinding.ensureInitialized();
await WindowsSingleInstance.ensureSingleInstance(
args,
"custom_identifier",
onSecondWindow: (args) {
print(args);
});
runApp(const MyApp());
}
```