XYZ Goat Flutter Challenge - Scenario B
Implement with clean architecture
and multiple repo in mind,
so that it can be scallable to be re-used in different apps
flutter_challenge_demo.mp4
- Flutter SDK : v3.0.5
- Dart SDK: v2.17.6
open terminal and run this command:
dart pub global activate melos
melos is a great tools to support multiple package flutter app, so we don't create a monolythic app.
reference : https://medium.com/flutter-community/managing-multi-package-flutter-projects-with-melos-c8ce96fa7c82
to download all the dependency you need to run the following commands,
this command will run flutter pub get
for all modules.
Doing that will be problematic because this project is contains multiple modules.
Fortunately, melos has easier way to do that.
open terminal and run this command:
melos bs
In-order to run the project you need to select run configuration based on environment.
For example if you want to run on development
environment, then you need to choose development
run configuration.
If you want to run on staging environment, then you need to choose staging
run configuration and so on.
In the project there are already included configuration for Android Studio
, and it will be detected automatically.
But, if you want to run using terminal, the command is :
flutter run --flavor development -t lib/src/main_development.dart
-
Library
base_asset
- containing all the asset for all the iconbase_component
- containing all the basic components for basic uicubit_util
- containing util that can be used for create cubit and cubit statelocalization
- library for generate localization automatically for every ui modulenetwork_client
- for calling API using library calleddio
nullable_util
- containing util for nullableresult_util
- containing helper for wraping api Resultservice_locator
- for dependency injection usingGetIt
test_util
- containing util related testing, also containing script to generatecoverage_test
file.
nb: coverage_test is work around to handle this issue flutter/flutter#27997
-
Entity
entity_book
- containing models related api and alsointerface
for Domain and Data Layerfake_entity_book
- containing fake class forinterface
inentity_book
so that can help in testing
-
Domain (unit test Written)
domain_book
- containing useCase in domain layerfake_domain_book
- containing fake class forusecase
indomain_book
so that can help in testing
-
Data (unit test partly written)
data_book
- containing implementation ofentity_book
interface usingnetwork_client
-
UI (unit test partly written for pages)
ui_book
- containing code for all the screens
-
Generate
coverage_test
files so that we can detect all coverage. If we're not doing this, the file that doesn't have a test file won't be able to be detected. The detail of the issue can be seen in here : flutter/flutter#27997flutter pub run test_util:generate_coverage_test.dart
-
Run all the test with coverage in all module
melos test_coverage
-
Combine all coverage data into one coverage file in
unit_test_report/lcov.info
melos gen_merged_coverage
-
Generate html report based on merged coverage data in
unit_test_report/lcov.info
the result will be in folderunit_test_report/loc_coverage_html_report/index.html
melos gen_html_merged_coverage
-
Open the coverage report in browser
unit_test_report/loc_coverage_html_report/index.html
open unit_test_report/loc_coverage_html_report/index.html
-
To delete all coverage data you can run this command
melos clean_coverage_data