पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv2.1.2

flutter_exit_app

एक फ्लटर प्लगइन जो डार्ट कोड में exit(0) कॉल किए बिना ऐप बंद करने का प्लेटफॉर्म-विशिष्ट तरीका प्रदान करता है।

AndroidiOS
30-दिन डाउनलोड
22.8 हज़ार
लाइक
62
Pub अंक
160

पैकेज इंस्टॉल करें

flutter pub add flutter_exit_app

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक फ्लटर प्लगइन जो प्लेटफॉर्म-विशिष्ट ऐप समाप्ति की अनुमति देता है, जिससे उपयोगकर्ता डार्ट के exit(0) का उपयोग किए बिना ऐप को आराम से बंद कर सकते हैं। यह एंड्रॉइड और आईओएस पर संगतता और सही व्यवहार सुनिश्चित करने के लिए मूल प्लेटफॉर्म विधियों का उपयोग करता है। इस प्लगइन का उद्देश्य उपयोगकर्ता के कार्यों (जैसे बैक बटन दबाना या मेनू से 'बंद' चुनना) के प्रति ऐप को साफ तरीके से बंद करने के लिए डेवलपर्स के लिए डिज़ाइन किया गया है। यह सीधे प्रक्रिया समाप्त करने से बचता है, जिससे बेहतर ऐप जीवनचक्र प्रबंधन को बढ़ावा मिलता है।

उपयोग

  • बैक प्रेस पर ऐप छोड़ना
  • एक एग्जिट पुष्टि डायलॉग का कार्यान्वयन करना
  • सेटिंग मेनू से ऐप बंद करना
  • किओस्क मोड में शांतिपूर्ण बंद करना
  • पूर्ण-स्क्रीन ऐप में एक्सिट का संभाल

मुख्य विशेषताएँ

  • प्लेटफॉर्म-विशिष्ट निकासी व्यवहार
  • exit(0) कॉल करने की आवश्यकता नहीं है
  • Android और iOS का समर्थन करता है
  • सरल API एकीकरण
  • एप्लिकेशन जीवनचक्र का सम्मान करता है

इनके लिए उपयुक्त

  • किओस्क या पूर्ण-स्क्रीन एप्लिकेशन बनाने वाले डेवलपर्स
  • निकास के पहले उपयोगकर्ता की पुष्टि की आवश्यकता होती है
  • मूल निकासी व्यवहार की आवश्यकता वाले प्रोजेक्ट्स
  • कस्टम नेविगेशन फ्लो वाले मोबाइल ऐप्स
  • Android और iOS दोनों के लिए लक्षित ऐप्स

विचार योग्य बातें

  • कुछ प्लेटफॉर्मों पर डिबग मोड में काम नहीं करता है
  • पृष्ठभूमि कार्यों के लिए अतिरिक्त हस्तक्षेप की आवश्यकता हो सकती है
  • परीक्षण के लिए exit(0) पर निर्भर ऐप्स के लिए उपयुक्त नहीं
  • निर्गमन समय के लिए सीमित नियंत्रण
  • Android पर सही अनुमति प्रबंधन की आवश्यकता होती है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

flutter_exit_app

A Flutter plugin that provides a platform-specific way to exit your application without calling exit(0) in Dart code.

Features

  • Android: Cleanly finishes the activity and removes it from the task list
  • iOS: Suspends the application (Apple guideline compliant) with optional force-exit
  • Modern implementation: Written in Kotlin (Android) and Swift (iOS)
  • Type-safe: Full null-safety support
  • Well-tested: Comprehensive unit tests

Platform Support

Platform Minimum Version
Android API 21 (Android 5.0)
iOS 12.0

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_exit_app: ^2.1.1

Then run:

flutter pub get

Usage

Import the package
import 'package:flutter_exit_app/flutter_exit_app.dart';
Basic exit (recommended)
// Exit the app using platform-specific methods
// iOS: Suspends the app (Apple guideline compliant)
// Android: Finishes activity and exits
await FlutterExitApp.exitApp();
Force exit on iOS (not recommended)
// Force-kill the iOS app process (against Apple guidelines)
// Only use when absolutely necessary
await FlutterExitApp.exitApp(iosForceExit: true);
Complete example
import 'package:flutter/material.dart';
import 'package:flutter_exit_app/flutter_exit_app.dart';

class ExitButton extends StatelessWidget {
  const ExitButton({super.key});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: () async {
        // Show confirmation dialog
        final shouldExit = await showDialog<bool>(
          context: context,
          builder: (context) => AlertDialog(
            title: const Text('Exit App'),
            content: const Text('Are you sure you want to exit?'),
            actions: [
              TextButton(
                onPressed: () => Navigator.pop(context, false),
                child: const Text('Cancel'),
              ),
              TextButton(
                onPressed: () => Navigator.pop(context, true),
                child: const Text('Exit'),
              ),
            ],
          ),
        );

        if (shouldExit == true) {
          await FlutterExitApp.exitApp();
        }
      },
      child: const Text('Exit App'),
    );
  }
}

Important Notes

iOS Guidelines

Apple's Human Interface Guidelines discourage apps from programmatically exiting. The plugin provides two modes:

Default mode (iosForceExit: false):

  • Animates the app to background with a smooth fade-out effect
  • Suspends the app gracefully
  • App remains in memory until iOS decides to terminate it
  • Recommended: This is the Apple-approved approach

Force exit mode (iosForceExit: true):

  • Animates the app with fade-out and scale-down effect
  • Forcibly terminates the process after animation
  • Warning: The app will appear to "crash" to users
  • May be rejected during App Store review
  • Only use if you have a specific requirement (e.g., enterprise apps)
Android Behavior

On Android, the plugin finishes the current activity and removes it from the recent tasks list, then exits the process after a 1-second delay to ensure clean shutdown. The app is completely removed from the task manager.

License

See the LICENSE file for details.

श्रेणियाँ

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट