start static method
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 argumentsshowLog: Whether to show the command being executedworkingDirectory: The working directory for the processprogressOut: Callback for stdout linesprogressErr: 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,
);
}