runFlutterRun function

Future<void> runFlutterRun(
  1. String project,
  2. void onProcessStarted(
    1. Process process
    ),
  3. void onMaybeLaunched()
)

flutter run

Implementation

Future<void> runFlutterRun(
  String project,
  void Function(Process process) onProcessStarted,
  void Function() onMaybeLaunched,
) async {
  final process = await runFlutter(
    project,
    const [
      'run',
      '-d',
      'chrome',
    ],
    onStdout: (msg) {
      final startWithKeyword = msg.startsWith(_appLaunchedKeyword);
      if (startWithKeyword) {
        onMaybeLaunched();
      }
      stdout.write(msg);
    },
    onStderr: (msg) {
      stdout.write(msg);
    },
  );

  onProcessStarted(process);

  await process.exitCode;
}