Skip to content

aliplayer_widget-v7.12.0

Choose a tag to compare

@Aqi-yu Aqi-yu released this 31 Mar 10:04
· 16 commits to master since this release

[7.12.0] – Custom Back Press Callback & Documentation Improvements

🚀 New Feature: Custom Back Press Callback

In previous versions, AliPlayerWidget handled the system back button event by default. However, many use cases—such as showing an exit confirmation or navigating to a specific route—require developers to intercept and customize this behavior, which wasn’t possible before. To address this, we’ve added a new onBackPressed callback parameter to AliPlayerWidget, giving you full control over the back press behavior.

How it works:

  • The onBackPressed callback is triggered whenever the user presses the back button while the player is active.
  • Return true → Event is handled; default navigation (Navigator.pop()) is prevented.
  • Return false or null → Default behavior (Navigator.pop()) is executed.

Enable advanced use cases like:

  • ✅ Showing a confirmation dialog before exiting full-screen playback
  • ✅ Navigating to a specific route (e.g., home feed) instead of simply popping the current screen
  • ✅ Implementing custom back-stack logic tailored for short-video or immersive viewing scenarios

Example usage:

AliPlayerWidget(
  onBackPressed: () {
    // Show exit confirmation
    showDialog(...);
    return true; // Handled — don't pop
  },
)