FLUTTER ECOSYSTEM

back_button_interceptor

Back Button Interceptor. May be used to do stuff when the Android back-button is tapped, as an alternative to `WillPopScope`.

Latest version
8.0.4
30-day downloads
426K
Likes
411
Pub points
150

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Overview

The back_button_interceptor package provides a way to intercept Android back button presses and execute custom logic before the app navigates back. It serves as an alternative to WillPopScope, offering more flexibility for handling navigation in Flutter apps on Android, iOS, Web, macOS, Windows, and Linux. This is particularly useful for showing confirmation dialogs, saving data, or managing complex navigation flows when users press the back button.

Use cases
  • Handling back button presses on mobile apps
  • Showing confirmation dialogs before navigation
  • Saving unsaved data before leaving a screen
  • Managing multi-level navigation flows
  • Preventing accidental navigation
  • Customizing back button behavior across platforms
Key features
  • Cross-platform support (Android, iOS, Web, macOS, Windows, Linux)
  • Simple API for intercepting back button events
  • Alternative to WillPopScope with better control
  • Supports nested route interception
  • Allows cancellation of back navigation
  • Works seamlessly with Navigator
Suitable for
  • Developers needing fine-grained control over back button behavior
  • Apps requiring confirmation before navigation
  • Multi-screen forms or wizards
  • Cross-platform Flutter applications
  • Teams avoiding WillPopScope limitations
Considerations
  • May require additional state management
  • Not needed if simple navigation is sufficient
  • Potential complexity in deeply nested navigation
  • Requires careful handling to avoid blocking navigation unintentionally
  • Limited to platform-specific back button events (not hardware buttons on all devices)
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add back_button_interceptor

Categories

Dependencies

Dependency list 1 items

Source repository

Related projects