checkAndShow static method
Shows the dialog when needed; onSkipOrNotAvailable runs when there is nothing to do, or the user taps Later / Skip this version.
Implementation
static Future<void> checkAndShow(List<UAppVersionResponse> versions, VoidCallback onSkipOrNotAvailable) async {
final UAppVersionResponse? info = versions.firstWhereOrNull((UAppVersionResponse i) => i.platform == TagAppVersion.current);
final UpdateType type = info == null ? UpdateType.none : _checkUpdate(info);
if (info == null || type == UpdateType.none || (type == UpdateType.optional && ULocalStorage.getInt(_skipKey) == info.latestBuildNumber)) {
onSkipOrNotAvailable();
return;
}
await showDialog(
barrierDismissible: false,
context: navigatorKey.currentContext!,
builder: (BuildContext context) => PopScope(
canPop: false,
child: _UUpdateDialogView(
info: info,
force: type == UpdateType.force,
onSkip: () {
ULocalStorage.set(_skipKey, info.latestBuildNumber);
UNavigator.back();
onSkipOrNotAvailable();
},
onLater: () {
UNavigator.back();
onSkipOrNotAvailable();
},
),
),
);
}