Fixed crash version check

This commit is contained in:
Juan Gilsanz Polo 2023-05-08 21:41:43 +02:00
parent 92c8e4d103
commit 6196cd369a

View file

@ -2,6 +2,7 @@ bool compareVersions({
required String currentVersion, required String currentVersion,
required String newVersion required String newVersion
}) { }) {
try {
final currentSplit = currentVersion.split('.').map((e) => int.parse(e)).toList(); final currentSplit = currentVersion.split('.').map((e) => int.parse(e)).toList();
final newSplit = newVersion.split('.').map((e) => int.parse(e)).toList(); final newSplit = newVersion.split('.').map((e) => int.parse(e)).toList();
@ -17,12 +18,16 @@ bool compareVersions({
else { else {
return false; return false;
} }
} catch (e) {
return false;
}
} }
bool compareBetaVersions({ bool compareBetaVersions({
required String currentVersion, required String currentVersion,
required String newVersion required String newVersion
}) { }) {
try {
final currentSplit = currentVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList(); final currentSplit = currentVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
final newSplit = newVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList(); final newSplit = newVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
@ -44,6 +49,9 @@ bool compareBetaVersions({
else { else {
return false; return false;
} }
} catch (e) {
return false;
}
} }
bool serverVersionIsAhead({ bool serverVersionIsAhead({
@ -51,11 +59,12 @@ bool serverVersionIsAhead({
required String referenceVersion, required String referenceVersion,
String? referenceVersionBeta String? referenceVersionBeta
}) { }) {
try {
final current = currentVersion.replaceAll('v', ''); final current = currentVersion.replaceAll('v', '');
final reference = referenceVersion.replaceAll('v', ''); final reference = referenceVersion.replaceAll('v', '');
final referenceBeta = referenceVersionBeta?.replaceAll('v', ''); final referenceBeta = referenceVersionBeta?.replaceAll('v', '');
if (current.contains('beta')) { if (current.contains('b')) {
if (referenceBeta != null) { if (referenceBeta != null) {
final currentSplit = current.split('-')[0].split('.').map((e) => int.parse(e)).toList(); final currentSplit = current.split('-')[0].split('.').map((e) => int.parse(e)).toList();
final newSplit = referenceBeta.split('-')[0].split('.').map((e) => int.parse(e)).toList(); final newSplit = referenceBeta.split('-')[0].split('.').map((e) => int.parse(e)).toList();
@ -106,4 +115,7 @@ bool serverVersionIsAhead({
return false; return false;
} }
} }
} catch (e) {
return false;
}
} }