flutter_alone 1.1.0 copy "flutter_alone: ^1.1.0" to clipboard
flutter_alone: ^1.1.0 copied to clipboard

Flutter desktop application single instance plugin

example/lib/main.dart

// example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_alone/flutter_alone.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final messageConfig = MessageConfig(
    type: MessageType.custom,
    customTitle: 'Example App',
    customMessage: 'App is already running!',
    showMessageBox: true,
  );

  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.'),
        ),
      ),
    );
  }
}
2
likes
0
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter desktop application single instance plugin

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_alone

Packages that implement flutter_alone