Understanding Default Flutter Project Structure

Alperen Yalçn
4 min readJan 14, 2022

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.

Default project structure in a Flutter project

.dart_tool Folder

This folder is came with Dart 2 version and used by pub and other tools. It replaced the .pub directory.

.idea Folder

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.

.vscode Folder

This folder contains a launch.json file. In this file vscode keeps some configuration about the project.

android Folder

İ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.

build 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

ios Folder

Same as android folder but this folder contains ios native code.

lib Folder

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.

main function that runs the app in main.dart

test Folder

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 test folder 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

.gitignore File

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.

.metadata File

This file tracks properties of this Flutter project (eg. version ,channel).Used by Flutter tool to assess capabilities and perform upgrades

.packages File

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.

analysis_option.yaml File

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.

include: package:lints/recommended.yaml

app.iml File

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.

pubspec.lock File

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.

pubspec.yaml File

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.

An example to pubspec.yaml file

README.md 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 👊.

--

--