update Readme
This commit is contained in:
parent
7fa6f99ad7
commit
be22a3d6fa
@ -1,21 +1,116 @@
|
||||
# wyatt_feature_brick
|
||||
# Feature Brick
|
||||
|
||||
[](https://github.com/felangel/mason)
|
||||
|
||||
A new brick created with the Mason CLI.
|
||||
|
||||
_Generated by [mason][1] 🧱_
|
||||
|
||||
## Getting Started 🚀
|
||||
|
||||
This is a starting point for a new brick.
|
||||
A few resources to get you started if this is your first brick template:
|
||||
A brick to create a feature using best practices and your state management of choice! Supports Bloc & Cubit.
|
||||
|
||||
- [Official Mason Documentation][2]
|
||||
- [Code generation with Mason Blog][3]
|
||||
- [Very Good Livestream: Felix Angelov Demos Mason][4]
|
||||
## How to use 🚀
|
||||
|
||||
[1]: https://github.com/felangel/mason
|
||||
[2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme
|
||||
[3]: https://verygood.ventures/blog/code-generation-with-mason
|
||||
[4]: https://youtu.be/G4PTjA6tpTU
|
||||
```
|
||||
mason make feature_brick --feature_name audit --state_management cubit --use_equatable true
|
||||
```
|
||||
|
||||
## Variables ✨
|
||||
|
||||
| Variable | Description | Default | Type |
|
||||
| ------------------ | ------------------------------- | ------- | --------- |
|
||||
| `feature_name` | The name of the feature | login | `string` |
|
||||
| `state_management` | The state management of the app | cubit | `enum` |
|
||||
| `use_equatable` | Use the equatable package | true | `boolean` |
|
||||
|
||||
## Outputs 📦
|
||||
|
||||
### Using Bloc
|
||||
|
||||
```shell
|
||||
--feature_name login --state_management bloc
|
||||
```
|
||||
|
||||
```
|
||||
├── feature
|
||||
│ ├── blocs
|
||||
| | └── feature_bloc
|
||||
│ │ ├── feature_bloc.dart
|
||||
│ │ ├── feature_event.dart
|
||||
│ │ └── feature_state.dart
|
||||
│ ├── state_management
|
||||
| | └── ...
|
||||
│ └── feature.dart
|
||||
└── ...
|
||||
```
|
||||
|
||||
- {{featureName}}_bloc.dart
|
||||
|
||||
```dart
|
||||
class FeatureBloc extends Bloc<FeatureEvent, FeatureState> {
|
||||
// TODO: Add repo if needed
|
||||
FeatureBloc() : super(const FeatureInitial()) {
|
||||
on<CustomFeatureEvent>(_onCustomFeatureEvent);
|
||||
}
|
||||
|
||||
FutureOr<void> _onCustomFeatureEvent(
|
||||
CustomFeatureEvent event,
|
||||
Emitter<FeatureState> emit,
|
||||
) {
|
||||
// TODO: Add your logic
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- {{featureName}}.dart
|
||||
|
||||
only one event is generated. It is up to you to rename it and add other events.
|
||||
|
||||
```dart
|
||||
class CustomFeatureEvent extends FeatureEvent {}
|
||||
```
|
||||
|
||||
- {{featureName}}_state.dart
|
||||
|
||||
only one state is generated. It is up to you to rename it and add other states.
|
||||
|
||||
```dart
|
||||
class FeatureInitial extends FeatureState {
|
||||
const FeatureInitial() : super();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Using Cubit
|
||||
|
||||
```shell
|
||||
--feature_name login --state_management cubit
|
||||
```
|
||||
|
||||
```
|
||||
├── feature
|
||||
│ ├── cubits
|
||||
| | └── feature_cubit
|
||||
│ │ ├── feature_cubit.dart
|
||||
│ │ └── feature_state.dart
|
||||
│ ├── state_management
|
||||
| | └── ...
|
||||
│ └── feature.dart
|
||||
└── ...
|
||||
```
|
||||
|
||||
- {{featureName}}_cubit.dart
|
||||
|
||||
```dart
|
||||
class FeatureCubit extends Cubit<FeatureState> {
|
||||
// Add repo if needed
|
||||
FeatureCubit() : super(const FeatureInitial());
|
||||
|
||||
FutureOr<void> yourCustomFunction() {
|
||||
// TODO: Add your logic
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{featureName}}_state.dart is the same file as before
|
||||
|
||||
### None
|
||||
TODO
|
Loading…
x
Reference in New Issue
Block a user