getDartBinVersion function

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 result =
      await runExecutableArguments('dart', ['--version'], verbose: false);

  // 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;
}