FlutterSmartExit class
A customizable widget that intercepts back button presses and shows a confirmation UI (bottom sheet, dialog, or double-tap-to-exit SnackBar).
Wrap your main screen with FlutterSmartExit to enable controlled app exits.
Example:
FlutterSmartExit(
exitType: ExitType.popUpExit,
child: HomeScreen(),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FlutterSmartExit
Constructors
- FlutterSmartExit({Key? key, required ExitType exitType, Widget? exitImage, String? exitMessage, TextStyle? exitMessageStyle, String? cancelButtonText, TextStyle? cancelButtonTextStyle, ButtonStyle? cancelButtonStyle, String? exitButtonText, TextStyle? exitButtonTextStyle, ButtonStyle? exitButtonStyle, Color? backgroundColor, double? bottomSheetHeight, double? backPressExitBottomExit, double? exitImageContainerHeight, double? exitImageContainerWidth, Decoration? exitImageContainerDecoration, required Widget child})
-
Creates a FlutterSmartExit widget.
const
Properties
- backgroundColor → Color?
-
Background color for the popup, bottom sheet, or SnackBar.
final
- backPressExitBottomExit → double?
-
Vertical margin for the SnackBar during back press exit.
final
- bottomSheetHeight → double?
-
Optional height for the bottom sheet.
final
- cancelButtonStyle → ButtonStyle?
-
Custom button style for the cancel button.
final
- cancelButtonText → String?
-
Text to display on the cancel button.
final
- cancelButtonTextStyle → TextStyle?
-
Text style for the cancel button.
final
- child → Widget
-
The main child widget wrapped by this exit handler.
final
- exitButtonStyle → ButtonStyle?
-
Custom button style for the exit button.
final
- exitButtonText → String?
-
Text to display on the exit button.
final
- exitButtonTextStyle → TextStyle?
-
Text style for the exit button.
final
- exitImage → Widget?
-
Optional image widget to display inside exit popup or bottom sheet.
final
- exitImageContainerDecoration → Decoration?
-
Decoration applied to the container surrounding the exit image
(e.g., border radius, background color, shadows).
final
- exitImageContainerHeight → double?
-
Height of the container that wraps the exit image.
final
- exitImageContainerWidth → double?
-
Width of the container that wraps the exit image.
final
- exitMessage → String?
-
The exit confirmation message.
final
- exitMessageStyle → TextStyle?
-
Custom style for the exit message text.
final
- exitType → ExitType
-
Type of exit behavior (bottom sheet, popup, or double back press).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FlutterSmartExit> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited