diff --git a/lib/backend/update/utils.dart b/lib/backend/update/utils.dart index 56510cd3..e1f9c13a 100644 --- a/lib/backend/update/utils.dart +++ b/lib/backend/update/utils.dart @@ -60,7 +60,7 @@ Future _checkAppUpdate({ await Future.delayed(delayAtLeast); } if (!context.mounted) return; - if (latest.version > currentVersion) { + if (latest.version.compareToIncludingBuild(currentVersion) > 0) { await context.showSheet( (ctx) => ArtifactUpdatePage(info: latest), dismissible: false, @@ -74,6 +74,24 @@ Future _checkAppUpdate({ } } +extension VersionEx on Version { + int compareToIncludingBuild(Version other) { + final result = compareTo(other); + if (result == 0) { + final thisBuild = int.tryParse(build); + final otherBuild = int.tryParse(other.build); + if (thisBuild != null && otherBuild == null) { + return 1; + } else if (thisBuild == null && otherBuild != null) { + return -1; + } else if (thisBuild != null && otherBuild != null) { + return thisBuild.compareTo(otherBuild); + } + } + return result; + } +} + Version? _getSkippedVersion() { final skippedVersionRaw = Settings.update.skippedVersion; if (skippedVersionRaw != null) {