flutter_alone 1.1.1
flutter_alone: ^1.1.1 copied to clipboard
A Flutter plugin for preventing duplicate execution of desktop applications with customizable message support and cross-user detection
import 'package:flutter/material.dart';
import 'package:flutter_alone/flutter_alone.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final messageConfig = CustomMessageConfig(
customTitle: 'Example App',
messageTemplate: 'Application is already running by {domain}\\{userName}',
);
if (!await FlutterAlone.instance.checkAndRun(messageConfig: messageConfig)) {
return;
}
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void dispose() {
FlutterAlone.instance.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Alone Example'),
),
body: const Center(
child:
Text('The app ran normally with custom message configuration.'),
),
),
);
}
}