md_feature
Brick for creating new feature from template using the mason š§±
[TOC]
Getting Started š
Requirements
This brick requires packages to be installed
- flutter_bloc
- dio
- retrofit
- build_runner (as dev dependency)
- retrofit_generator (as dev dependency)
(All required dependencies can be added automatically using post_gen.dart
hook with optional function)
Installation
Initialize and add brick using mason_cli
# šÆ Activate from https://pub.dev
dart pub global activate mason_cli
# š Initialize mason
mason init
# š¦ Install the brick
mason add md_feature
To create a feature, you must provide values:
- project_name - name of the project to import package (you can take it from
name
field insidepubspec.yaml
of the project) - feature_name - name of the created feature, for example if path to your features directory is
lib/src/features/
, providesrc/features
- path_to_feature - path to the generated feature to add path imports
- use_fvm - is project uses fvm for flutter versioning
You can create json
file for persistent variable values
{
"project_name": "example_project",
"path_to_feature": "src/features",
"use_fvm": true
}
Use it with the command
mason make md_feature -c config.json
For custom output path provide additional -o
argument
mason make md_feature -c config.json -o lib/src/features/
Output
Created feature structure will look like this
ā {{feature}}
āāāā bloc
āāāāā {{feature}}_bloc.dart
āāāāā {{feature}}_bloc_data.dart
āāāāā {{feature}}_bloc_event.dart
āāāāā {{feature}}_bloc_state.dart
āāāā data
āāāāā data_source
āāāāāā {{feature}}_remote_data_source.dart
āāāāāā {{feature}}_remote_data_source.g.dart
āāāāā repository
āāāāāāā {{feature}}_repository_impl.dart
āāā domain
āāā interface
āāā i_{{feature}}_repository.dart
TODO
- describe every feature layer in the README.md
- create tests
- provide entity script example
- provide model script example