Solved: Why do we have .iml file in flutter


Asked by Manishyadav on December 28, 2021 (source).

After googling it I found this

IML is a module file created by IntelliJ IDEA, an IDE used to develop Java applications. It stores information about a development module, which may be a Java, Plugin, Android, or Maven component; saves the module paths, dependencies, and other settings.

But we already have Pubspec.yaml file for dependencies and plugins . So I wanted to know the actual use of .iml file in flutter.


Question answered by Peter H (source).

The pubspec.yaml file (Flutter) is used to declare your dependencies, fonts, and assets. After you declare the dependency there, you can then use it in your code.

While the .iml file is used for the project structure in IntelliJ IDEA, it is not specific to Flutter. Whenever you have for example an Android native or Java project you will have a .iml file in IntelliJ IDEA. Therefore, this file is basically a metadata for IntelliJ IDEA to know how to structure the project and what each folder will be used for, for example:

 <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
 <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />

Both .iml and idea/ will be generated when you create a Flutter project and both of them are used for IntelliJ IDEA, you shouldn't change anything in the .iml file and you don't have to commit it also since it will generated automatically.

Check also: