start static method

Future<int> start(
  1. String argument, {
  2. bool showLog = false,
  3. String? workingDirectory,
  4. void progressOut(
    1. String line
    )?,
  5. void progressErr(
    1. String line
    )?,
})

Starts a Flutter process and returns immediately.

This method starts a Flutter process and returns a Future that completes when the process exits. It allows for custom callbacks to handle stdout and stderr output.

Parameters:

  • argument: The Flutter command arguments
  • showLog: Whether to show the command being executed
  • workingDirectory: The working directory for the process
  • progressOut: Callback for stdout lines
  • progressErr: Callback for stderr lines

Returns: A Future that completes with the exit code

Example:

// Start Flutter pub get with custom output handling
await FlutterHelper.start('pub get',
  progressOut: (line) => print('OUT: $line'),
  progressErr: (line) => print('ERR: $line'),
);

// Start Flutter build in a specific directory
await FlutterHelper.start('build apk',
  workingDirectory: './my_flutter_app',
  showLog: true,
);

Implementation

static Future<int> start(
  String argument, {
  bool showLog = false,
  String? workingDirectory,
  void Function(String line)? progressOut,
  void Function(String line)? progressErr,
}) {
  String command = '${getCommandFlutter()} $argument';
  if (showLog) printMessage(command);
  return command.start(
    workingDirectory: workingDirectory,
    progressOut: progressOut,
    progressErr: progressErr,
  );
}