compatibleVersions property

List<String> get compatibleVersions

Returns all compatible version strings, sorted newest-first by semver.

Implementation

List<String> get compatibleVersions {
  final compatible = resultsByVersion.entries
      .where((e) => e.value.isCompatible)
      .map((e) => e.key)
      .toList();

  compatible.sort((a, b) {
    try {
      // Import-free: parse using split
      final aParts = a.split('.').map(int.tryParse).toList();
      final bParts = b.split('.').map(int.tryParse).toList();
      for (int i = 0; i < 3; i++) {
        final aP = i < aParts.length ? (aParts[i] ?? 0) : 0;
        final bP = i < bParts.length ? (bParts[i] ?? 0) : 0;
        if (bP != aP) return bP.compareTo(aP);
      }
      return b.compareTo(a);
    } catch (_) {
      return b.compareTo(a);
    }
  });

  return List.unmodifiable(compatible);
}