get static method

void get({
  1. bool force = false,
  2. RunOptions? runOptions,
  3. String? workingDirectory,
})

Run pub get on the current project. If force is true, this will execute even if the pubspec.lock file is up-to-date with respect to the pubspec.yaml file.

Implementation

static void get(
    {bool force = false, RunOptions? runOptions, String? workingDirectory}) {
  runOptions = mergeWorkingDirectory(workingDirectory, runOptions);
  final prefix = runOptions.workingDirectory == null
      ? ''
      : '${runOptions.workingDirectory}/';
  final pubspec = FileSet.fromFile(getFile('${prefix}pubspec.yaml'));
  final publock = FileSet.fromFile(getFile('${prefix}pubspec.lock'));

  if (force || !publock.upToDate(pubspec)) {
    _run('get', runOptions: runOptions);
  }
}