getPackageVersion static method

Version? getPackageVersion(
  1. String package
)

Implementation

static v.Version? getPackageVersion(String package) {
  if (containsPackage(package)) {
    var version = pubSpec.allDependencies[package]!;
    try {
      final json = version.toJson();
      if (json is String) {
        return v.Version.parse(json);
      }
      return null;
    } on FormatException catch (_) {
      return null;
    } on Exception catch (_) {
      rethrow;
    }
  } else {
    throw CliException(
        LocaleKeys.info_package_not_installed.trArgs([package]));
  }
}