pub method Null safety

  1. @protected
Future<ProcessResult> pub(
  1. String cmd,
  2. {List<String>? arguments = const [],
  3. bool immediatePrintStd = true,
  4. bool immediatePrintErr = true,
  5. String? workingDir}
)

Runs flutter pub command.

Implementation

@protected
Future<ProcessResult> pub(String cmd,
    {List<String>? arguments = const [],
    bool immediatePrintStd = true,
    bool immediatePrintErr = true,
    String? workingDir}) async {
  final executable = _getPlatformSpecificExecutableName('flutter');
  final args = [
    'pub',
    if (isVerbose) '-v',
    cmd,
    if (arguments != null) ...arguments,
  ];

  printVerbose('Run: $executable ${args.join(" ")}');

  return immediatePrintStd || immediatePrintErr
      ? runWithImmediatePrint(
          executable,
          args,
          printStdOut: immediatePrintStd,
          printErrOut: immediatePrintErr,
          workingDir: workingDir,
        )
      : Process.run(executable, args, workingDirectory: workingDir);
}