-
-
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_bloc v0.2.0 (#3545)
- Loading branch information
Showing
17 changed files
with
149 additions
and
38 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
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
23 changes: 1 addition & 22 deletions
23
bricks/hydrated_bloc/__brick__/{{name.snakeCase()}}_bloc.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,22 +1 @@ | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_event.dart'; | ||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Bloc extends HydratedBloc<{{name.pascalCase()}}Event, {{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Bloc() : super(const {{name.pascalCase()}}State()) { | ||
on<{{name.pascalCase()}}Event>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
|
||
@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_bloc }}{{/use_freezed}}{{#use_equatable}}{{> equatable_bloc }}{{/use_equatable}}{{#use_basic}}{{> basic_bloc }}{{/use_basic}} |
6 changes: 1 addition & 5 deletions
6
bricks/hydrated_bloc/__brick__/{{name.snakeCase()}}_event.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()}}_bloc.dart'; | ||
|
||
abstract class {{name.pascalCase()}}Event { | ||
const {{name.pascalCase()}}Event(); | ||
} | ||
{{#use_freezed}}{{> freezed_event }}{{/use_freezed}}{{#use_equatable}}{{> equatable_event }}{{/use_equatable}}{{#use_basic}}{{> basic_event }}{{/use_basic}} |
6 changes: 1 addition & 5 deletions
6
bricks/hydrated_bloc/__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()}}_bloc.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,22 @@ | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_event.dart'; | ||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Bloc extends HydratedBloc<{{name.pascalCase()}}Event, {{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Bloc() : super(const {{name.pascalCase()}}State()) { | ||
on<{{name.pascalCase()}}Event>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
|
||
@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()}}_bloc.dart'; | ||
|
||
abstract class {{name.pascalCase()}}Event { | ||
const {{name.pascalCase()}}Event(); | ||
} |
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()}}_bloc.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,23 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_event.dart'; | ||
part '{{name.snakeCase()}}_state.dart'; | ||
|
||
class {{name.pascalCase()}}Bloc extends HydratedBloc<{{name.pascalCase()}}Event, {{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Bloc() : super(const {{name.pascalCase()}}State()) { | ||
on<{{name.pascalCase()}}Event>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
|
||
@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()}}_bloc.dart'; | ||
|
||
abstract class {{name.pascalCase()}}Event extends Equatable { | ||
const {{name.pascalCase()}}Event(); | ||
|
||
@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,8 @@ | ||
part of '{{name.snakeCase()}}_bloc.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,24 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:hydrated_bloc/hydrated_bloc.dart'; | ||
|
||
part '{{name.snakeCase()}}_event.dart'; | ||
part '{{name.snakeCase()}}_state.dart'; | ||
part '{{name.snakeCase()}}_bloc.freezed.dart'; | ||
|
||
class {{name.pascalCase()}}Bloc extends HydratedBloc<{{name.pascalCase()}}Event, {{name.pascalCase()}}State> { | ||
{{name.pascalCase()}}Bloc() : super(const {{name.pascalCase()}}State.initial()) { | ||
on<{{name.pascalCase()}}Event>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
|
||
@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()}}_bloc.dart'; | ||
|
||
@freezed | ||
class {{name.pascalCase()}}Event with _${{name.pascalCase()}}Event { | ||
const factory {{name.pascalCase()}}Event.started() = _Started; | ||
} |
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()}}_bloc.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_bloc | ||
description: Generate a new HydratedBloc in Dart. Built for the bloc state management library. | ||
version: 0.1.2 | ||
version: 0.2.0 | ||
repository: https://github.com/felangel/bloc/tree/master/bricks/hydrated_bloc | ||
|
||
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 bloc class. | ||
default: counter | ||
prompt: Please enter the bloc name. | ||
style: | ||
type: enum | ||
description: The style of bloc generated. | ||
default: basic | ||
prompt: What is the bloc 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_bloc_hooks | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
mason: ^0.1.0-dev |