PlayxUpdateDialog class

A platform-adaptive Flutter widget that displays an update dialog.

On Android, it renders a Material AlertDialog. On iOS, it renders a Cupertino CupertinoAlertDialog. This widget is used by PlayxVersionUpdate.showUpdateDialog to present update prompts.

It requires PlayxVersionUpdateInfo which contains details about the update (e.g., current version, new version, whether it's a force update, and store URL).

The appearance and behavior of the dialog are highly customizable via PlayxUpdateUIOptions. You can set custom titles, descriptions, button texts, and apply TextStyle and ButtonStyle to various elements.

Features:

  • Platform Adaptive: Automatically renders Material dialog on Android and Cupertino dialog on iOS.
  • Customizable Content: Control the text for the title, description, release notes title, update button, and dismiss button using uiOptions.
  • Styling Options: Apply custom TextStyle and ButtonStyle to various text and button elements for a branded look.
  • Release Notes: Optionally display release notes (PlayxVersionUpdateInfo.releaseNotes) by setting uiOptions.showReleaseNotes to true.
  • Dismissibility: The dialog's dismissibility is controlled by uiOptions.isDismissible. By default, it's non-dismissible if versionUpdateInfo.forceUpdate is true.
  • Action Callbacks: Provides callbacks uiOptions.onUpdate and uiOptions.onCancel for custom logic when buttons are pressed. If onUpdate is not provided, it defaults to opening the app store via PlayxVersionUpdate.openStore using the specified uiOptions.launchMode. If onCancel is not provided for a non-dismissible (force) update, it defaults to SystemNavigator.pop() to close the app.

Behavior:

  • If versionUpdateInfo.canUpdate is false or if running on web, this widget returns SizedBox.shrink() (an empty widget).
  • Uses PopScope to manage system back button behavior based on isDismissible.

Example Usage (Typically used by showUpdateDialog):

// This dialog is typically shown internally by PlayxVersionUpdate.showUpdateDialog
// based on the uiOptions.presentation setting.
await PlayxVersionUpdate.showUpdateDialog(
  context: context,
  options: PlayxUpdateOptions(
    googlePlayId: 'com.example.app',
    appStoreId: 'com.example.app',
  ),
  uiOptions: PlayxUpdateUIOptions(
    presentation: PlayxUpdateDisplayType.dialog, // Explicitly request a dialog
    title: (info) => 'App Update ${info.newVersion}!',
    description: (info) => 'A critical update is available. Please update now.',
    releaseNotesTitle: (info) => 'What\'s New:',
    showReleaseNotes: true,
    isDismissible: false, // Make the dialog non-dismissible
    updateButtonText: 'Update App',
    dismissButtonText: 'Exit', // For non-dismissible, might be 'Exit'
    updateButtonTextStyle: TextStyle(fontSize: 18, color: Colors.white),
    updateButtonStyle: ElevatedButton.styleFrom(backgroundColor: Colors.blue),
  ),
);

@see PlayxVersionUpdateInfo for update details. @see PlayxUpdateUIOptions for customization options. @see PlayxVersionUpdate.showUpdateDialog for the primary method to display this dialog.

Inheritance

Constructors

PlayxUpdateDialog({Key? key, required PlayxVersionUpdateInfo versionUpdateInfo, required PlayxUpdateUIOptions uiOptions})
const

Properties

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
uiOptions PlayxUpdateUIOptions
final
versionUpdateInfo PlayxVersionUpdateInfo
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<PlayxUpdateDialog>
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