isDependency function

Future<bool> isDependency(
  1. String package,
  2. BuildStep buildStep, {
  3. bool dev = false,
})

Implementation

Future<bool> isDependency(String package, BuildStep buildStep,
    {bool dev = false}) async {
  final pubspec = Pubspec.parse(await buildStep
      .readAsString(AssetId(buildStep.inputId.package, 'pubspec.yaml')));
  var deps = pubspec.dependencies;
  if (dev) {
    deps = pubspec.devDependencies;
  }
  return deps.keys.any((key) => key == package);
}