extractVersion method
Implementation
@visibleForTesting
String extractVersion(String tool, String output) {
final lines = output.trim().split('\n');
if (lines.isEmpty) return '';
var line = lines.first.trim();
line = line.replaceAll('•', '-');
line = line.replaceAll(RegExp(r'[^\x00-\x7F]'), '');
if (tool == 'Dart') {
final match = RegExp(r'Dart SDK version: (\S+)').firstMatch(line);
if (match != null) return 'Dart ${match.group(1)}';
}
if (tool == 'Flutter') {
final match = RegExp(r'Flutter (\S+)').firstMatch(line);
if (match != null) return 'Flutter ${match.group(1)}';
}
if (tool == 'Xcode') {
final match = RegExp(r'Xcode (\S+)').firstMatch(line);
if (match != null) return 'Xcode ${match.group(1)}';
}
if (tool == 'Chrome') {
final match = RegExp(r'(\d+\.\d+\.\d+\.\d+)').firstMatch(line);
if (match != null) return 'Chrome ${match.group(1)}';
}
return line;
}