How to Setup Folder Structure in Flutter

Flutter Login App

In this flutter tutorial, we will learn how to set up a folder structure in a flutter, where to put assets of our flutter project & how to create a flutter package that can be reused in any other flutter app.

Prerequisite

This is the 2nd tutorial of our Flutter Login App Series. The next tutorial is about how to set up a theme in a flutter.

Most of the time we start creating apps without even thinking about folder structures. But along the way, we start realizing that finding some file in the messy structure becomes hectic.

When building large Flutter apps, one of the first things we should decide is how to structure our project.

This ensures that the entire team can follow a clear convention and add features in a consistent manner.

Watch Youtube tutorial

 

Types of Folder Structures in Flutter

Flutter is a flexible platform, as it does not restrict its users to design folder in a specific way, whereas, it allow us to design a folder or project structure that suit our requirements, flexibility and need.

In flutter, we can adopt any folder structure we like and can also use MVC, MVVM combined with the folder structures defined below.

As there is no specific structure in flutter so in general, flutter community adopts 2 types of flutter structures:-

  1. Feature First
  2. Layer First

Lets talk about each of them in detail.

1. Layer based Flutter Structure

To keep things simple, suppose we have only two features in the app.

If we adopt the layer-first approach, our project structure may look like this: 

Flutter Project Structure Feature-first or Layer-first

2. Features based Flutter Structure

The feature-first approach demands that we create a new folder for every new feature that we add to our app. And inside that folder, we can add the layers themselves as sub-folders.

Using the same example as above, we would organize our project like this:

 

Flutter Project Structure Feature-first or Layer-first

How to create a Custom Package in Flutter

While creating flutter apps, there are many features that need to be reused over and over again in other systems.

Specially, if you are working in a software house, or in some company where you don’t want to redo the development, we can create Packages in flutter.

Flutter packages can be created any where in the project structure but the recommended location to create a flutter package is under root folder or we can create folder called packages and in it we can create our packages.

Package that we will create in flutter app series will be auth_repository.

To create a package in flutter, follow the following steps:-

  1. Open terminal
  2. Terminal should point out to your location where you want to create your package
  3. Write the command flutter create –template package package_name
flutter create --template package auth_repository

Let's Connect

Videos are always a better source for in-depth knowledge. So, connect with me at YouTube.

Download Project

Flutter Login App UI Source Code- How to Create a complete Flutter app - Flutter education app - Flutter app UI Design - Flutter Course - Flutter Complete App 2022
Dashboard Source COde - Dashboard design in flutter - flutter dashoard - flutter app design 2022 - Flutter UI - Flutter homepage

Latest Courses

Flutter Login App UI Source Code- How to Create a complete Flutter app - Flutter education app - Flutter app UI Design - Flutter Course - Flutter Complete App 2022
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Latest Tutorials

Flutter Profile page UI Design - Flutter app design 2023 - Profile Screen Flutter UI - Flutter 2023
Flutter Firebase phone authentication - Firebase Phone auth tutorial in flutter - Flutter Firebase phone number authentication 2022
Firebase Authentication in flutter - Flutter firebase authentication 2022 - firebase auth tutorial 2022 - firebase flutter auth
How to setup firebase in flutter 2022 - Flutter firebase setup
Dashboard Source COde - Dashboard design in flutter - flutter dashoard - flutter app design 2022 - Flutter UI - Flutter homepage

Join Our Mailing List

Join our mailing list to receive the latest, Free Courses, Video Tutorials, free codes and updates regarding Tutorials and services. You will also start getting coupons on the related services.

You have Successfully Subscribed!