mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
improve code
This commit is contained in:
@@ -12,6 +12,14 @@ extension FSExt on FileSystemEntity {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deleteIgnoreError() async {
|
||||
try {
|
||||
await delete();
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
int get size {
|
||||
if (this is File) {
|
||||
return (this as File).lengthSync();
|
||||
|
@@ -8,8 +8,14 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
Future<String> getLatestVersion() async {
|
||||
var dio = AppDio();
|
||||
var res = await dio
|
||||
.get("https://api.github.com/repos/wgh136/pixes/releases/latest");
|
||||
return (res.data["tag_name"] as String).replaceFirst("v", "");
|
||||
.get("https://raw.githubusercontent.com/wgh136/pixes/refs/heads/master/pubspec.yaml");
|
||||
var lines = (res.data as String).split("\n");
|
||||
for (var line in lines) {
|
||||
if (line.startsWith("version:")) {
|
||||
return line.split(":")[1].split('+')[0].trim();
|
||||
}
|
||||
}
|
||||
throw "Failed to get latest version";
|
||||
}
|
||||
|
||||
/// Compare two versions.
|
||||
|
Reference in New Issue
Block a user