Workout app in Flutter with GetX architecture
- First execute build_runner:
flutter pub run build_runner build
- Then run project with:
flutter run
- Overall Architecture.
Clean architecture is most correct approach for me as it's dividing app codebase into multiple layers: DataSources (remote & local), Repository. It's providing a nice and consistent way of accessing data. With Futures and Streams it's easy to implement single access or observable data. UseCases are not mandatory though they can help managing complexity of e.g. multiple repositories usage.
- State management + MVC
I found GetX to be one of most efficient state managements existing in Flutter frameworks. Developing features is rapid, and there is zero boilerplate with .obs fields. UI is detecting changes itself (thanks to Obx widget) so everything is very reactive meaning you always have latest data presented. If not GetX, I would go for BLoC with cubits.
With GetX you end up with Controller per each page (screen) so it forces MVC (MVVM) pattern. However all data obtained by View from Controller is observable! I also use RxDart as a nice addition for managing observable data.
- Model creation
For model creation I used freezed package so I get .copyWith and equals for free.
- Persistent storage
I would use Hive or get_storage for saving workouts so they are accessible after app restarted. I didn't use them because of time limitation.
Take a look at: https://github.com/adamstyrc/workout-flutter/blob/main/media/sample.mp4