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.showReleaseNotestotrue. - Dismissibility: The dialog's dismissibility is controlled by
uiOptions.isDismissible. By default, it's non-dismissible ifversionUpdateInfo.forceUpdateis true. - Action Callbacks: Provides callbacks
uiOptions.onUpdateanduiOptions.onCancelfor custom logic when buttons are pressed. IfonUpdateis not provided, it defaults to opening the app store viaPlayxVersionUpdate.openStoreusing the specifieduiOptions.launchMode. IfonCancelis not provided for a non-dismissible (force) update, it defaults toSystemNavigator.pop()to close the app.
Behavior:
- If
versionUpdateInfo.canUpdateisfalseor if running on web, this widget returnsSizedBox.shrink()(an empty widget). - Uses
PopScopeto manage system back button behavior based onisDismissible.
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
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PlayxUpdateDialog
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