use of io.flutter.actions.FlutterDoctorAction in project flutter-intellij by flutter.
the class FlutterModuleBuilder method commitModule.
@Nullable
@Override
public Module commitModule(@NotNull Project project, @Nullable ModifiableModuleModel model) {
final String basePath = getModuleFileDirectory();
if (basePath == null) {
Messages.showErrorDialog("Module path not set", "Internal Error");
return null;
}
final VirtualFile baseDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(basePath);
if (baseDir == null) {
Messages.showErrorDialog("Unable to determine Flutter project directory", "Internal Error");
return null;
}
final FlutterSdk sdk = getFlutterSdk();
if (sdk == null) {
Messages.showErrorDialog("Flutter SDK not found", "Error");
return null;
}
final OutputListener listener = new OutputListener();
final PubRoot root = runFlutterCreateWithProgress(baseDir, sdk, project, listener, getAdditionalSettings());
if (root == null) {
final String stderr = listener.getOutput().getStderr();
final String msg = stderr.isEmpty() ? "Flutter create command was unsuccessful" : stderr;
final int code = FlutterMessages.showDialog(project, msg, "Project Creation Error", new String[] { "Run Flutter Doctor", "Cancel" }, 0);
if (code == 0) {
new FlutterDoctorAction().startCommand(project, sdk, null);
}
return null;
}
FlutterSdkUtil.updateKnownSdkPaths(sdk.getHomePath());
// Create the Flutter module. This indirectly calls setupRootModule, etc.
final Module flutter = super.commitModule(project, model);
if (flutter == null) {
return null;
}
FlutterModuleUtils.autoShowMain(project, root);
addAndroidModule(project, model, basePath, flutter.getName());
return flutter;
}
Aggregations