checkForUpdate function
Implementation
Future<void> checkForUpdate() async {
const currentVersion = "1.1.2";
final response = await http.get(
Uri.parse("https://pub.dev/api/packages/flutter_enterprise_cli"),
);
if (response.statusCode != 200) {
print("⚠ Unable to check for updates.");
return;
}
final data = jsonDecode(response.body);
final latestVersion = data["latest"]["version"];
if (latestVersion != currentVersion) {
print("⚡ New CLI version available!");
print("Current: $currentVersion");
print("Latest : $latestVersion\n");
print("Run this to update:");
print("dart pub global activate flutter_enterprise_cli");
} else {
print("✅ CLI is up to date.");
}
}