hasDependency method

bool hasDependency(
  1. String name
)

Check if a dependency exists.

Implementation

bool hasDependency(String name) {
  // Simple check - look for the dependency name in dependencies section
  final lines = content.split('\n');
  bool inDependencies = false;

  for (final line in lines) {
    if (line.trim() == 'dependencies:') {
      inDependencies = true;
      continue;
    }
    if (inDependencies) {
      // Check if we've left the dependencies section
      if (line.isNotEmpty && !line.startsWith(' ') && !line.startsWith('\t')) {
        inDependencies = false;
        continue;
      }
      // Check for the dependency
      if (line.trim().startsWith('$name:')) {
        return true;
      }
    }
  }
  return false;
}