Make your flutter projects scalable — Best folder structure for your next project

A rapidly growing project with changing plans all the time is a real nightmare for every developer. The only way to get out of this is to plan.

I struggled all the time because of stupid folder structures. And I didn’t want you guys to go through all that scrap again.

In this article, I’ll introduce you to my folder structure which you can use in your projects too.

Let’s consider the odds

I want a folder structure that:

  • Easy to scale if I want to add a feature.
  • Separates my business logic from my views (UI).
  • Easy to remove any of the modules.
  • Easy to identify where my components are.
  • Easy to change any routes if ever needed.
  • Easy to update my theme.
  • Easy to connect to the new backend if ever required.

Here it is, we want something easy and flexible. So, Here is what I discovered.

Let’s try this way

I just want to make it simple. So no technical terms but a simple explanation.

The folder structure I use in my projects
  • Views: Let’s group all your views(screens) into a single folder. Further group the views into separate modules. You may have modules like auth, profile, onboarding,…
Inside Views folder
  • Controllers: All the business logic and state management logic goes in here. You may place your logic for providers, blocs or any other state management logic into this folder. You may even rename this as your state management architecture like providers, blocs,…
Providers/Controllers folder
  • Services: Whatever data that comes into your app must have to be from here. It may be connecting with REST API or any DB connection.
Services folder
  • Models: Place all your models in here like user_model.dart, product_model.dart or any other. I’ll publish a different article on how to use models to make your project more structured.
Models folder
  • Config: Here goes everything that controllers your app likes constants, routes, themes…
Config folder
  • Assets: Create a folder “assets” at the project level. It is a common convention to name it “assets”. But you are free to go with whatever you feel. But be consistent throughout your projects. Further, you may group your assets based on their type like images, Html, fonts,…
Assets folder

Is this the only way?

No, not at all. You may go with any architecture or folder structure that suits best for you. This one works for me. I hope so, that It will work for you guys too.

Just give it a try and see if it works for you. Make changes wherever you feel until you find something that works for you. If you find anything better than this. Let me know in the comments.

Share this article with flutter nerds, who need this. Don’t forget to give a like to this article.

💡 Learn Flutter in a Simplified way 📱 Develop Android & IOS Apps 🔥 Unleash the power of Flutter