build static method

void build({
  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 void build({
  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);

  runlib.run(sdkBin('dart'), arguments: args, runOptions: runOptions);
}