Skip to content

Commit aa64df5

Browse files
authored
Fix SDK browsing NPE in FlutterSettingsConfigurable (#8102)
If no file is selected, the file chooser will return `null`. This guards against that. Fixes: #8069
1 parent f2c29c5 commit aa64df5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ protected void textChanged(@NotNull final DocumentEvent e) {
141141
}
142142

143143
private void createUIComponents() {
144+
//noinspection DialogTitleCapitalization
144145
ExtendableTextComponent.Extension browseExtension =
145146
ExtendableTextComponent.Extension.create(
146147
AllIcons.General.OpenDisk,
@@ -149,7 +150,10 @@ private void createUIComponents() {
149150
() -> {
150151
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
151152
VirtualFile file = FileChooser.chooseFile(descriptor, mySdkCombo, null, null);
152-
mySdkCombo.setItem(file.getPath());
153+
if (file != null) {
154+
//noinspection DataFlowIssue (sure to be set before the extension is invoked)
155+
mySdkCombo.setItem(file.getPath());
156+
}
153157
});
154158
mySdkCombo = new ComboBox<>();
155159
mySdkCombo.setEditor(new BasicComboBoxEditor() {

0 commit comments

Comments
 (0)