I have decided to write the flutter project structure for developers who have not been used to android or iOS package structure or even for beginners who want to be familiar with the flutter environement.
In last tutorial, we have learned to create and run your flutter project. Yet, if you don’t know about it please visit our flutter proect creation and deployment tutorial.
Before explaining flutter project structure i am going to introduce an important tools in flutter known as Pub.
Pub
Pub is the package manager for the dart programming language containing libraries and packages for flutter.
Pub is the package management tool which has list of commands for configuring, debugging, testing and managing your flutter project.
So initially when you create any flutter project you will find out the flutter project/package structure as below :
We are going to discuss all the important packages and files listed in your project structure as above.
Initially you will see two main packages. One is your Project Root Package (In above image, fluttersample) and other one is External Libraries.
Project Root Package
Project package will contain all the packages and files related to your flutter coding, testing and maintenance.
.idea
.idea package contains project configuration settings like dart sdk, flutter plugins, project workspace and many more. All the configuration files will be stored in xml file forms. Generally, you will never need to approach this package.
android
android package will contain all the packages and files related to your native android app. If you’ve ever worked with android platform you will find this package familiar. Whenever you want to implement any android specific feature you have to work with this package directories.
In android, AndroidManifest.xml is the core file containing all the essential information about configuration details of your android app.
ios
Similar to android package, ios package will also contain all the packages and files related to your native ios app. Whenever you want to implement any native ios specific feature you have to work in this package directories.
In ios, Info.plist is the core file containing all the essential information about configuration details of your ios app.
lib
This is our main flutter package in which we have to write our flutter code. By default, when you create a project you will find out a main.dart file in your lib folder. So, this main.dart file will have a main function from where your flutter app execution starts.
Also, lib is the package in which you are going to create and write all the dart files (as flutter uses dart as its development language) containing your app source code.
By default, main.dart file will have some code written in it (you can say this a flutter’s hello world application). So that you can test and run something you can interact in your flutter app.
Test
This package will contain files for writing and running software tests to ensure that your flutter app is working correctly before release. By default, it will contain a dart file named as widget_test.dart for software testing.
.flutter-plugins
This file lists the information about third party packages you uses in your flutter project.
.gitignore
As name suggests, this hidden file stores lists of different files which you don’t want to upload to your git system while pulling or pushing your source code to git system.
.metadata
.metadata file contains the information about the flutter properties like stable sdk channel, project type etc.
.packages
.packages file contains information about all the dart packages included inside the external libraries in your flutter project.
<appname.iml>
This file contains configuration information about the packages and modules used by the IDE.
pubspec.lock
This file conatins detailed information(like, dependency name, description, meta, source, version and many more information) about all the dart packages included in your flutter project.
pubspec.yaml
pubspec.yaml is an essential file containing all the flutter project related information like project name, project details, sdk version details, third packages or dependencies used in the project, assets(like images, files, fonts) you want to use in your project etc.
README.md
This is an option file provided for developer reference. Any developer can add different kinds of information about flutter project so that other developers can read and understand it. This file is like comments in program or say explanatory documentation about flutter project.
Okay, so we have done our part o understanding the flutter project structure. You will get used to this project structure. So, don’t worry and get going through our tutorials.
Our next tutorial is flutter widgets covering what widget is and how they works to build your app UI.
If you find out our flutter tutorials then share it with your friends and comment down your suggestions to help us in making our tutorials more interesting for other users.
Feel free to ask your questions in the comment section. Keep reading and commenting your suggestions to make toastguyz a better site to learn different programming languages.