isDartOldVersion static method
Implementation
static Future<bool> isDartOldVersion(String version) async {
final processResult = await Process.run(
'dart',
<String>['--version'],
runInShell: true
);
final versionOutput = processResult.stdout.toString().trim();
final versionMatch = RegExp(r'version: ([\d\.]+)').firstMatch(versionOutput);
if (versionMatch != null) {
final sdkVersion = versionMatch.group(1);
if (sdkVersion != null) {
final numericSdkVersion = Converter.convertToThousands(int.tryParse(sdkVersion.replaceAll('.', '')));
final numericCurrentVersion = Converter.convertToThousands(int.tryParse(version.replaceAll('.', '')));
if (numericSdkVersion != null && numericCurrentVersion != null) {
if (numericSdkVersion < numericCurrentVersion) {
return true;
}
}
}
}
return false;
}