How to organize dart files inside packages in flutter

First of all, in Flutter we don't deal with activities or fragments directly, that is a naming convention from Android itself.

There are many options to architect your app and organize your folders. I wouldn't say that there is a holy grail solution. So you have to try some of them and see the best fit for you.

At the end of this article, I show an option to a folder structure when working with flavors, like this:

Flavoring

But there are plenty of others, so I recommend you to see how some of the GitHub projects are organized, a good way to start is having a look at the projects from this repository. Especially the 'Open Source Apps' section.


I'm currently working on a project that follows an approach like you described. I don't know if it's the better structure, but it works really nice for me.

\lib
  \-model
  \-api
  \-bloc
  \-widgets (commom components)
  \-exceptions
  \-config (config classes/files like routes, theme, specific settings for each environment - dev, production, test)
  \-views
    \-login
    \-home
    \-user_profile
    \-...
  \-main.dart

----- EDITED -----

After work for almost a year with Flutter, I've tested some different structures, and there's one in particular that's really nice and provides an amazing organization...

Take a look at slidy, the following image represents the kind of organization it provides. More details in the package description.

project organization example

Tags:

Dart

Flutter