Flutter Clean Architecture w/ BLoC, Get_It & Hive
App to showcase demo for how to have Clean Architecture in Flutter with Get_It for dependency injection, BLoC for state maintainence and Hive for persisting data into database.
Getting Started
This project is to showcase how we can use Clean Architure in Flutter App. The architecture of the app is as follows -
The existing folder structure of the project is as belows -
Stream
> getFeedPostsDatabaseStream() {
if (_feedBox == null) {
_initializeHiveBox();
}
return _feedBox!.watch().map((event) => List
.generate(
_feedBox!.values.length, (index) => _feedBox!.getAt(index)!));
}
Above function will create a Stream to listen for all the changes in the database. This then can be used to update the values automatically on feed_screen.dart
.
Run Project
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
Then you can run the project as usual