windows_single_instance 0.1.7 copy "windows_single_instance: ^0.1.7" to clipboard
windows_single_instance: ^0.1.7 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) {
    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"),
        ),
      ),
    );
  }
}
45
likes
140
pub points
94%
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