parseAvailability static method
Parses the machine-readable availability value when Shorebird emits it, and otherwise conservatively reports no available patch.
Implementation
static bool parseAvailability(String output) {
final trimmed = output.trim();
if (trimmed.isEmpty) return false;
try {
final decoded = jsonDecode(trimmed);
if (decoded is Map<Object?, Object?>) {
final available = decoded['available'];
if (available is bool) return available;
final updateAvailable = decoded['updateAvailable'];
if (updateAvailable is bool) return updateAvailable;
}
} on FormatException {
// Human-readable Shorebird output is handled conservatively below.
}
final normalized = trimmed.toLowerCase();
if (normalized.contains('no update') ||
normalized.contains('no patch') ||
normalized.contains('up to date')) {
return false;
}
return normalized.contains('update available') ||
normalized.contains('patch available');
}