flutter_alone 1.1.0
flutter_alone: ^1.1.0 copied to clipboard
Flutter desktop application single instance plugin
flutter_alone #
A robust Flutter plugin for preventing duplicate execution of desktop applications.
Features #
- Prevent multiple instances of Windows desktop applications
- Cross-user detection support
- System-wide mutex management
- Customizable message handling
- Multi-language support (English, Korean, Custom)
- Safe resource cleanup
Platform Support #
| Windows | macOS | Linux |
|---|---|---|
| ✅ | 🚧 | 🚧 |
Getting Started #
Add flutter_alone to your pubspec.yaml:
dependencies:
flutter_alone: ^1.1.0
Usage #
Import the package:
import 'package:flutter_alone/flutter_alone.dart';
Initialize in your main function:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final messageConfig = MessageConfig(
type: MessageType.en, // Language selection
showMessageBox: true, // Message box display control
);
if (!await FlutterAlone.instance.checkAndRun(messageConfig: messageConfig)) {
exit(0); // Exit if another instance is running
}
runApp(const MyApp());
}
Clean up resources:
@override
void dispose() {
FlutterAlone.instance.dispose();
super.dispose();
}
Additional Information #
Windows Implementation #
- Uses Windows Named Mutex for system-wide instance detection
- Implements cross-user detection through global mutex naming
- Ensures proper cleanup of system resources