Flutter Single Instance

Provides utilities for handiling single instancing in Flutter.

Platform Support
Android ⚠️
iOS ⚠️
Web ⚠️
macOS
Windows
Linux

✅ - Confirmed working.
⚠️ - Always reports as first instance.

Installation

Add flutter_single_instance as a dependency in your pubspec.yaml file.

flutter pub add flutter_single_instance

MacOS

Disable sandboxing in macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements files.

<key>com.apple.security.app-sandbox</key>
<false/>

Usage

A simple usage example:

import 'package:flutter_single_instance/flutter_single_instance.dart';

main() async {
  WidgetsFlutterBinding.ensureInitialized();

  if(await FlutterSingleInstance().isFirstInstance()){
    runApp(MyApp());
  }else{
    print("App is already running");

    exit(0);
  }
}

Web and other unsupported platforms

You can safely use this package in web and other unsupported platforms. It will always return true for isFirstInstance method.

Libraries

flutter_single_instance
Provides utilities for handiling single instancing in Flutter.