run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  final String clientDir = Project.clientDir;

  if (!Directory(clientDir).existsSync()) {
    Logger.fail('Client directory not found: $clientDir');
    exit(1);
  }

  final String? sdkPath = Project.config.client.flutterSdkPath;
  final String flutter = sdkPath != null
      ? '$sdkPath${PlatformInfo.separator}bin${PlatformInfo.separator}flutter'
      : 'flutter';

  // Pass all remaining arguments directly to flutter run
  final List<String> args = <String>['run', ...argResults!.rest];

  Logger.ok('$flutter ${args.join(' ')}');

  final int exitCode = await Shell.runInteractive(
    flutter,
    args,
    workingDirectory: clientDir,
  );

  exit(exitCode);
}