Search in sources :

Example 1 with FlutterCommand

use of io.flutter.sdk.FlutterCommand in project flutter-intellij by flutter.

the class SdkFields method createFlutterSdkRunCommand.

/**
 * Create a command to run 'flutter run --machine'.
 */
public GeneralCommandLine createFlutterSdkRunCommand(@NotNull Project project, @Nullable FlutterDevice device, @NotNull RunMode mode) throws ExecutionException {
    final MainFile main = MainFile.verify(filePath, project).get();
    final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project);
    if (flutterSdk == null) {
        throw new ExecutionException(FlutterBundle.message("flutter.sdk.is.not.configured"));
    }
    final PubRoot root = PubRoot.forDirectory(main.getAppDir());
    if (root == null) {
        throw new ExecutionException("Entrypoint isn't within a Flutter pub root");
    }
    String[] args = additionalArgs == null ? new String[] {} : additionalArgs.split(" ");
    if (buildFlavor != null) {
        args = ArrayUtil.append(args, "--flavor=" + buildFlavor);
    }
    final FlutterCommand command = flutterSdk.flutterRun(root, main.getFile(), device, mode, args);
    return command.createGeneralCommandLine(project);
}
Also used : FlutterCommand(io.flutter.sdk.FlutterCommand) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)1 PubRoot (io.flutter.pub.PubRoot)1 FlutterCommand (io.flutter.sdk.FlutterCommand)1 FlutterSdk (io.flutter.sdk.FlutterSdk)1