buildAsync static method

Future buildAsync({
  1. String? mode,
  2. List<String>? directories,
  3. RunOptions? runOptions,
  4. String? outputDirectory,
  5. String? workingDirectory,
})

Run pub build on the current project.

The valid values for mode are release and debug.

Implementation

static Future buildAsync(
    {String? mode,
    List<String>? directories,
    RunOptions? runOptions,
    String? outputDirectory,
    String? workingDirectory}) {
  runOptions = mergeWorkingDirectory(workingDirectory, runOptions);
  final args = ['pub', 'build'];
  if (mode != null) args.add('--mode=$mode');
  if (outputDirectory != null) args.add('--output=$outputDirectory');
  if (directories != null && directories.isNotEmpty) args.addAll(directories);

  return runlib
      .runAsync(sdkBin('dart'), arguments: args, runOptions: runOptions)
      .then((_) => null);
}