-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bricks): hydrated_cubit v0.2.0 (#3546)
- Loading branch information
Showing
13 changed files
with
114 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
# 0.2.0 | ||
|
||
- feat: add support for `equatable` | ||
- feat: add support for `freezed` | ||
|
||
# 0.1.3 | ||
|
||
- fix: part and imports | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 1 addition & 17 deletions
18
bricks/hydrated_cubit/__brick__/{{name.snakeCase()}}_cubit.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1 @@ | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Cubit extends HydratedCubit<{{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Cubit() : super(const {{name.pascalCase()}}State()); | ||
|
||
@override | ||
Map<String, dynamic> toJson({{name.pascalCase()}}State state) { | ||
// TODO: implement toJson | ||
} | ||
|
||
@override | ||
{{name.pascalCase()}}State fromJson(Map<String, dynamic> json) { | ||
// TODO: implement fromJson | ||
} | ||
} | ||
{{#use_freezed}}{{> freezed_cubit }}{{/use_freezed}}{{#use_equatable}}{{> equatable_cubit }}{{/use_equatable}}{{#use_basic}}{{> basic_cubit }}{{/use_basic}} |
6 changes: 1 addition & 5 deletions
6
bricks/hydrated_cubit/__brick__/{{name.snakeCase()}}_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
part of '{{name.snakeCase()}}_cubit.dart'; | ||
|
||
class {{name.pascalCase()}}State { | ||
const {{name.pascalCase()}}State(); | ||
} | ||
{{#use_freezed}}{{> freezed_state }}{{/use_freezed}}{{#use_equatable}}{{> equatable_state }}{{/use_equatable}}{{#use_basic}}{{> basic_state }}{{/use_basic}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Cubit extends HydratedCubit<{{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Cubit() : super(const {{name.pascalCase()}}State()); | ||
|
||
@override | ||
Map<String, dynamic> toJson({{name.pascalCase()}}State state) { | ||
// TODO: implement toJson | ||
} | ||
|
||
@override | ||
{{name.pascalCase()}}State fromJson(Map<String, dynamic> json) { | ||
// TODO: implement fromJson | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
part of '{{name.snakeCase()}}_cubit.dart'; | ||
|
||
class {{name.pascalCase()}}State { | ||
const {{name.pascalCase()}}State(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Cubit extends HydratedCubit<{{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Cubit() : super(const {{name.pascalCase()}}State()); | ||
|
||
@override | ||
Map<String, dynamic> toJson({{name.pascalCase()}}State state) { | ||
// TODO: implement toJson | ||
} | ||
|
||
@override | ||
{{name.pascalCase()}}State fromJson(Map<String, dynamic> json) { | ||
// TODO: implement fromJson | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
part of '{{name.snakeCase()}}_cubit.dart'; | ||
|
||
class {{name.pascalCase()}}State extends Equatable { | ||
const {{name.pascalCase()}}State(); | ||
|
||
@override | ||
List<Object> get props => []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_state.dart'; | ||
part '{{name.snakeCase()}}_cubit.freezed.dart'; | ||
|
||
class {{name.pascalCase()}}Cubit extends HydratedCubit<{{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Cubit() : super(const {{name.pascalCase()}}State.initial()); | ||
|
||
@override | ||
Map<String, dynamic> toJson({{name.pascalCase()}}State state) { | ||
// TODO: implement toJson | ||
} | ||
|
||
@override | ||
{{name.pascalCase()}}State fromJson(Map<String, dynamic> json) { | ||
// TODO: implement fromJson | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
part of '{{name.snakeCase()}}_cubit.dart'; | ||
|
||
@freezed | ||
class {{name.pascalCase()}}State with _${{name.pascalCase()}}State { | ||
const factory {{name.pascalCase()}}State.initial() = _Initial; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
name: hydrated_cubit | ||
description: Generate a new HydratedCubit in Dart. Built for the bloc state management library. | ||
version: 0.1.3 | ||
version: 0.2.0 | ||
repository: https://github.com/felangel/bloc/tree/master/bricks/hydrated_cubit | ||
|
||
environment: | ||
mason: ">=0.1.0-dev.15 <0.1.0" | ||
mason: ">=0.1.0-dev.32 <0.1.0" | ||
|
||
vars: | ||
name: | ||
type: string | ||
description: The name of the cubit class. | ||
default: counter | ||
prompt: Please enter the cubit name. | ||
style: | ||
type: enum | ||
description: The style of cubit generated. | ||
default: basic | ||
prompt: What is the cubit style? | ||
values: | ||
- basic | ||
- equatable | ||
- freezed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:mason/mason.dart'; | ||
|
||
Future<void> run(HookContext context) async { | ||
final style = context.vars['style']; | ||
context.vars = { | ||
...context.vars, | ||
'use_basic': style == 'basic', | ||
'use_equatable': style == 'equatable', | ||
'use_freezed': style == 'freezed', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: hydrated_cubit_hooks | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
mason: ^0.1.0-dev |