Understanding Default Flutter Project Structure
Hi, if you are wondering what files is for what in a Flutter project you are in the right article :) . We are going to examine auto generated project structure when you create a new Flutter project.
This folder is came with Dart 2 version and used by pub and other tools. It replaced the .pub directory.
This folder is auto generated if you are using JetBrain’s IDEs(eg. Android Studio, PyCharm, Intellij). Project settings are stored with each specific project as a set of xml files in this folder. So you dont have to worry about deleting this folder.
This folder contains a launch.json file. In this file vscode keeps some configuration about the project.
İf you came from native app development this folder might be familiar because this folder contains native code. Most of time you dont need to change anything inside this folder but if you want to interact with low level functions(eg. camera,bluetooth,gps) you need to edit this folder.
This folder might not come when you create the project but it will come when you first build the project. It contains compiled code of your project. The output paths is listed below.
- Web = root/build/web/
- Android = root/build/app/outputs/flutter-apk/app.apk
- Ios = root/build/ios/archive/MyApp.xcarchive
Same as android folder but this folder contains ios native code.
This is the folder where we will be mostly hangaround because we will write our Flutter code into this folder. By default lib folder contains only main.dart file. Main.dart is like a car ignition because app starts running from main.dart. Also the folder structure inside lib folder is very important for organizing and managing application. I am planning to write an article about folder structure.
This is the folder where we will write our test for the application. According to the flutter cookbook
‘In general, test files should reside inside a
testfolder located at the root of your Flutter application or package. Test files should always end with
_test.dart, this is the convention used by the test runner when searching for tests’
There are three types test exist in Flutter which we will cover later.
- Unit test
- Widget test
- Integration tests
This file contains a list about files which you dont want/need to upload to your hosted codebase(eg. gitHub, azure) while pushing or pulling. So if you dont want a file to be uploaded you just need to add that file into .gitignore file.
This file tracks properties of this Flutter project (eg. version ,channel).Used by Flutter tool to assess capabilities and perform upgrades
This file contains all packages include external packages used in the project but now this file is deprecated.Instead of this file .dart_tool/package_config.json used for this purpose.
This files configurations(linter rules) is configures Dart analyzer which checks your all codes and if your codes has any conflict with the configurations you wrote than IDE gives an error or warn. I recommend you to use the package called flutter_lints and you can use this package with the code above inside analysis_option.yaml.
This file is used for the project structure in JetBrains IDEs, it is not specific to Flutter. So this file is basically a metadata for IDEs to know how to structure the project and what folders is used for what.
This file is contains all the packages version , dependency and description informations used in the project. Purpose is keep the app packages locked in the same library version so if we run the app in different computer we dont have to struggle with code issue caused from different package version.
This file controls app name, Sdk version, packages , dependencies and assets(eg. custom fonts, local image, icons). If you want to add new packages to your project you need to add the package name under dependencies section but how many space you used before the package name is very important for this file.
In default this markdown file contains some resource to get started into Flutter for beginners but you can use this file for app description.
Now you have knowledge about Flutter’s project structure. See you in the next article 👊.