getDartBinVersion function Null safety

Future<Version?> getDartBinVersion()

Parse flutter version

Implementation

Future<Version?> getDartBinVersion() async {
  // $ dart --version
  // Linux: Dart VM version: 2.7.0 (Unknown timestamp) on "linux_x64"
  var cmd = DartCmd(['--version']);
  var result = await runCmd(cmd);

  // Take from stderr first
  var version = parseDartBinVersionOutput(result.stderr.toString().trim());
  // Take stdout in case it changes
  version ??= parseDartBinVersionOutput(result.stdout.toString().trim());
  return version;
}