5

So i have created some apps in flutter with laravel backend, which works online only. Now i need to make an app work offline as well for which i am thinking of using Hive. But now the problem is i cannot find a good resource on how to properly manage such large project. My past projects were mostly small, but with local storage and all, i want to use interfaces & repositories to manage the project. But i can't figure out how to put everything together so the code is manageable.

So can someone help me here? Is there any such project that i can study, or perhaps even an article or a video. Anything that sheds light on how to structure large projects in flutter will be appreciated.

Ashok
  • 369
  • 5
  • 16

1 Answers1

8

There is no right or wrong on how to structure your Flutter project. You can put everything in a single file. Also it depends on the package its being used, for example I use BLoC as state management and these are some project structures that the package recommends:

I don't use any of those, I made my own project structure that I will explain in a moment. There's a package layout convention for Dart (not for Flutter projects).

I use the following structure:

├──lib/
│  ├──blocs/
│  ├──models/ 
│  ├──repositories/
│  ├──screens/
│  ├──utils/
│  ├──widgets/
│  └──main.dart

I separate everything in folders so front-end devs can work on the widgets folder where there is all the design stuff and back-end devs can works on the blocs folder where there is all the logic.

Remember there is no wrong or right answer. Check-out your recommended project structure that your favorite state management package recommends or watch this talk: Keep it Simple, State: Architecture for Flutter Apps (DartConf 2018)

Classy-Bear
  • 881
  • 11
  • 19
  • is it necessary if we add more cubits folder if we also want to use cubits? – Arief Wijaya Jun 09 '21 at 10:19
  • @AriefWijaya Yes you can, after the cubit release I create a state management folder and put all the files with this naming convention: file_cubit.dart or file_bloc.dart – Classy-Bear Jul 04 '21 at 17:40
  • Could you please explain what repositories should stand for? – Philipos D. Jan 13 '22 at 14:48
  • @PhiliposD. Here are some links that may help: https://en.wikipedia.org/wiki/Software_repository https://bloclibrary.dev/#/architecture?id=repository – Classy-Bear Jan 24 '22 at 04:10