exec function Null safety

Future<ProcessResult> exec(
  1. String executable,
  2. List<String> arguments,
  3. {String? workingDirectory,
  4. bool silent = false,
  5. Map<String, String>? environment}

Runs a command in a shell. Returns a ProcessResult once the process has terminated.

Processes executed by this command are queued, and they cannot run in parallel (to preserve consistency in logs). A new process will not start until the previous ones have terminated. Use execInParallel to run a process in parallel.

By default, the outputs will be printed on the console. If silent is true, nothing will be printed but the outputs will still be available in ProcessResult.

Use workingDirectory to set the working directory for the process. Note that the change of directory occurs before executing the process on some platforms, which may have impact when using relative paths for the executable and the arguments.

Use environment to set the environment variables for the process. If not set the environment of the parent process is inherited. Currently, only US-ASCII environment variables are supported and errors are likely to occur if an environment variable with code-points outside the US-ASCII range is passed in.


Future<ProcessResult> exec(
  String executable,
  List<String> arguments, {
  String? workingDirectory,
  bool silent = false,
  Map<String, String>? environment,
}) async {
  return _lock.synchronized(
    () => _exec(