getBreakingChangesForVersionRange method
Return breaking changes that apply when upgrading Flutter from
fromVersion to toVersion (exclusive of from, inclusive of to).
Changes whose version could not be determined are included as well since they may still be relevant.
Implementation
Future<List<Map<String, dynamic>>> getBreakingChangesForVersionRange(
String fromVersion,
String toVersion,
) async {
final allChanges = await fetchBreakingChanges();
if (allChanges.isEmpty) return [];
try {
final from = Version.parse(fromVersion);
final to = Version.parse(toVersion);
return allChanges.where((entry) {
final versionStr = entry['version'] as String?;
if (versionStr == null || versionStr.isEmpty) {
// Include entries without a clear version — they may still be
// relevant and the caller can further filter if needed.
return true;
}
try {
final version = Version.parse(versionStr);
return version > from && version <= to;
} catch (_) {
// Unparseable version string — include by default.
return true;
}
}).toList();
} catch (e, stack) {
Logger.error(
'Error filtering breaking changes for range '
'$fromVersion -> $toVersion',
e,
stack,
);
return allChanges;
}
}