v1.2.0
windows_single_instance
强制您的 Windows 应用程序仅有一个实例,当打开新实例时,将现有窗口置于前端。
55喜欢 1.9万近 30 天下载150Pub 分数
Windows
SongbookPro/flutter_windows_single_instance open-source repository details.
{"sdk":"flutter"}>=6.0.0 <7.0.0>=1.0.0 <3.0.0{"sdk":"flutter"}^6.0.0以下为英文项目原文快照,最新内容请访问 GitHub。
Restrict a Windows app to only be able to open one instance at a time.
WidgetsFlutterBinding.ensureInitialized(); to the start of your apps main function.async modifier to your apps main function.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.void main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
await WindowsSingleInstance.ensureSingleInstance(
args,
"custom_identifier",
onSecondWindow: (args) {
print(args);
});
runApp(const MyApp());
}