double_tap_exit 0.0.2 copy "double_tap_exit: ^0.0.2" to clipboard
double_tap_exit: ^0.0.2 copied to clipboard

retracted

Flutter package for request double back pressed before close app/route/screen. Wrap any widget with it to use.

DoubleTapExit Flutter Package #

This Flutter package allows you to require a double back press to close an app, route, or screen. This is useful to prevent accidental exits and improve user experience.

Usage #

Default #

To use the DoubleTap widget with default settings, wrap your main widget with DoubleTap and provide a message to display when the back button is pressed for the first time.

import 'package:flutter/material.dart';
import 'package:your_package_name/double_tap.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DoubleTap(
        message: "Press back again to close",
        child: Home(),
      ),
    );
  }
}


### Custom

import 'package:flutter/material.dart';
import 'package:your_package_name/double_tap.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DoubleTap(
        message: "Press back again to close",
        child: Home(),
        // Optional style
        textStyle: TextStyle(
          fontSize: 13,
          color: Colors.white,
        ),
        background: Colors.red,
        backgroundRadius: 30,
      ),
    );
  }
}



Parameters
• message: A string message that is shown to the user when they press the back button for the first time.
• child: The main widget to be displayed.
• waitForSecondBackPress: (Optional) An integer value representing the number of seconds to wait for the • • second back press. Default is 2 seconds.
• onFirstBackPress: (Optional) A callback function that is executed when the back button is pressed for the first time.
• condition: (Optional) A boolean condition to check before showing the toast. Default is true.
• onConditionFail: (Optional) A callback function that is executed when the condition is false.
• textStyle: (Optional) A TextStyle object to customize the appearance of the message text. Default is white color and font size 14.
• background: (Optional) A Color object to set the background color of the toast. Default is semi-transparent black.
• backgroundRadius: (Optional) A double value to set the border radius of the toast background. Default is 20.
2
likes
0
points
139
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package for request double back pressed before close app/route/screen. Wrap any widget with it to use.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on double_tap_exit