startWithStdin static method

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

Starts a Flutter process with stdin forwarding for interactive commands.

This method is specifically designed for interactive Flutter commands that require user input (like Flutter run with hot reload support). It forwards stdin from the parent process to the Flutter process, allowing for interactive development workflows.

Parameters:

  • argument: The Flutter command arguments
  • showLog: Whether to show the command being executed
  • singleCharacterMode: Whether to enable single character input mode (for hot keys)
  • workingDirectory: The working directory for the process
  • progressOut: Callback for stdout lines
  • progressErr: Callback for stderr lines

Example:

// Start Flutter app with hot reload support
await FlutterHelper.startWithStdin('run');

// Start Flutter app with single character mode for hot keys
await FlutterHelper.startWithStdin('run', singleCharacterMode: true);

Note: This method should only be used for interactive commands that require user input. For non-interactive commands, use run or start instead.

Implementation

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