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.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:windows_single_instance/windows_single_instance.dart';

void main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();
  await WindowsSingleInstance.ensureSingleInstance(args, "instance_checker", onSecondWindow: (args) {
    // ignore: avoid_print
    print(args);
  });
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const Center(
          child: Text("Demo"),
        ),
      ),
    );
  }
}
39
likes
120
pub points
92%
popularity

Publisher

verified publishersongbook-pro.com

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