Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter lib folder - Missing Menu option Create New Folder #2539

Closed
Sun3 opened this issue Aug 9, 2018 · 22 comments
Closed

Flutter lib folder - Missing Menu option Create New Folder #2539

Sun3 opened this issue Aug 9, 2018 · 22 comments

Comments

@Sun3
Copy link

Sun3 commented Aug 9, 2018

Steps to Reproduce

  1. Create New Flutter Project in Android Studio
  2. Right Click the lib folder to open Menu
  3. New Folder (Directory) is missing from option

Note, the only way to create Folders is to create a New Dart File with a new Folder name before it. This is very inconvenient when trying to create multiple folders without content.

Version info

flutter doctor -v
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale en-US)
• Flutter version 0.5.1 at /Users/doe/Development/flutter
• Framework revision c7ea3ca377 (2 months ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
• Android SDK at /Users/doe/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
• CocoaPods version 1.5.2

[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 27.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Connected devices (1 available)
• iPhone X • 705E75D9-7E01-4AB5-948A-226B8AFD9F8A • ios • iOS 11.4 (simulator)

• No issues found!

Thank you.

@stevemessick
Copy link
Member

Apparently, IntelliJ (and, therefore, Android Studio) interprets source folders in Java terms. Instead of creating new folders it wants you to create new packages. I'm not sure what we can do about that, since it isn't something we control.

We need to mark the lib folder as a source folder to ensure indexing and other behind-the-scenes operations are enabled.

@Sun3
Copy link
Author

Sun3 commented Aug 9, 2018

In my test the IntelliJ IDEA editor for the lib folder, it has the Create Directory in the menu option. Just the Android Studio does not. :)

@pq pq added this to the Backlog milestone Aug 9, 2018
@stevemessick
Copy link
Member

Looks like it depends on the version of IntelliJ. This isn't something we'll be changing.

@biancashouse
Copy link

Just to confirm. While I agree there is no New Folder menu option, the New Package does the job: I found that doing a mkdir is equivalent to using the New Package meu option.

@feinstein
Copy link

Curious thing, I added the folders from Windows Explorer and they appear as a java package on IntelliJ IDEA.... but a project I cloned from git, such as flutter_architecture_samples have all the folders showing as regular folders.

@stevemessick
Copy link
Member

flutter_architecture_samples (by @brianegan) is a collection of Flutter projects. IIRC the project directories do not have IntelliJ meta-data so they may not look right in IntelliJ. But they also don't have extraneous clutter, so people can focus on the architecture being illustrated.

@ph55
Copy link

ph55 commented Jan 12, 2020

Happened to me when created app via command line - flutter create myapp.
Doesn't happen though when creating app via IntelliJ.

@yvonmanzi
Copy link

@ph55 yeah, same! it only happens when you create a project using flutter create in the terminal. It is honestly quite awful.

@dominikseger
Copy link

Under File-> Project Structure-> Module-> Source-Tab you can unmark the /lib folder. This worked for me as a workaround.

Credits: https://stackoverflow.com/questions/51491363/how-to-create-directory-folder-in-android-studio

@yvonmanzi
Copy link

@Phpadawan Thanks for your suggestion. It ended up working for me as well. Now all is great:) thanks and all the best.!

@Rakibahsaf
Copy link

I am also having the same problem on my new project. But on my last project"Directory" option was visible

@yvonmanzi
Copy link

@Rakibahsaf I don't know how or why it happens, but yes sometimes you have that option and other times you don't. Have you tried doing what @Phpadawan suggested?

@0maigod
Copy link

0maigod commented Jun 17, 2020

I try what @Phpadawan proposed, but i can just do one level of folder, i can't nested one in other, if i tried to do that, studio change the name of the folder including the two names, by example if i have a folder named "bloc" and i want to create a new folder inside with the name "code", studio change the name of the folder "bloc" to "bloc.code"... any suggestion?

@trafalgarLawA
Copy link

or you can simply use VS code to create folders inside folders

@alexverbitsky
Copy link

I don't have "Project Structure" under "File" in my Flutter project

@alexverbitsky
Copy link

alexverbitsky commented Aug 26, 2020

I don't have "Project Structure" under "File" in my Flutter project

In case you didn't create Flutter project via Android Studio (using CLI), you may need to do the following steps to see "Project Structure" menu option:

  1. Go to "your_project/.idea/misc.xml"
  2. Add one more "component" inside the "project" tag:
  <component name="ProjectType">
    <option name="id" value="io.flutter" />
  </component>
  1. Restart Android Studio

Then you'll be able to get to "File -> Project Structure -> Module -> Sources" and unmark "lib" as a source folder. As it's suggested above

image

Android Studio recognizes folder named "lib" as a folder for packages by default, so that's the reason why a "Directory'" cannot be created inside

@tloshi
Copy link

tloshi commented Oct 7, 2020

I would suggest to check if you have the file yourProjectName.iml in the root folder of project. If that file does not exist then Android Studio doesn't know which folder structure to create and for this you cannot see you lib folder when it displays the window to set the flutter entry point.

@Jaivins
Copy link

Jaivins commented Nov 19, 2020

check this one
https://stackoverflow.com/questions/49138139/android-studio-stuck-when-creating-new-flutter-project

@livintan
Copy link

Go to file > Click Project Structure > Click Module > Click Lib > Unmark sources > Click Apply

@Mohammedkasemaltarhony
Copy link

Go to file > Click Project Structure > Click Module > Click Lib > Unmark sources > Click Apply

it is working for me now thanks

@vietstone-ng
Copy link

@livintan Worked! But do you know why is that?

@katesaikishore
Copy link

I right-clicked on myproject.iml and clicked on import, which worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests