Skip to content

Commit 6e34252

Browse files
authored
feat: Added Mason bricks for cubit screen and freezed model (#70)
1 parent 9fb8172 commit 6e34252

18 files changed

+148
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
.history
1010
.svn/
1111

12+
# Mason
13+
.mason/
14+
mason-lock.json
15+
1216
# IntelliJ related
1317
*.iml
1418
*.ipr

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ analyzer:
134134
- '**/*.g.dart'
135135
- '**/*.gen.dart'
136136
- '**/*.gr.dart'
137+
- 'bricks'
137138
- 'lib/generated_plugin_registrant.dart'
138139
errors:
139140
invalid_annotation_target: ignore

bricks/mason.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bricks:
2+
xl_cubit_screen:
3+
path: xl_cubit_screen
4+
xl_model_freezed:
5+
path: xl_model_freezed

bricks/xl_cubit_screen/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 0.1.0+1
2+
3+
- TODO: Describe initial release.

bricks/xl_cubit_screen/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.

bricks/xl_cubit_screen/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# xl_screen
2+
3+
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason)
4+
5+
A new brick created with the Mason CLI.
6+
7+
_Generated by [mason][1] 🧱_
8+
9+
## Getting Started 🚀
10+
11+
This is a starting point for a new brick.
12+
A few resources to get you started if this is your first brick template:
13+
14+
- [Official Mason Documentation][2]
15+
- [Code generation with Mason Blog][3]
16+
- [Very Good Livestream: Felix Angelov Demos Mason][4]
17+
18+
[1]: https://github.com/felangel/mason
19+
[2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme
20+
[3]: https://verygood.ventures/blog/code-generation-with-mason
21+
[4]: https://youtu.be/G4PTjA6tpTU
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:bloc/bloc.dart';
2+
import 'package:freezed_annotation/freezed_annotation.dart';
3+
4+
part '{{name.snakeCase()}}_state.dart';
5+
6+
part '{{name.snakeCase()}}_cubit.freezed.dart';
7+
8+
class {{name.pascalCase()}}Cubit extends Cubit<{{name.pascalCase()}}State> {
9+
{{name.pascalCase()}}Cubit() : super(const {{name.pascalCase()}}State.state());
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:flutter/widgets.dart';
2+
import 'package:flutter_bloc/flutter_bloc.dart';
3+
4+
import '{{name.snakeCase()}}_cubit.dart';
5+
6+
class {{name.pascalCase()}}Screen extends StatelessWidget {
7+
const {{name.pascalCase()}}Screen({Key? key}) : super(key: key);
8+
9+
@override
10+
Widget build(BuildContext context) => BlocProvider(
11+
create: (_) => {{name.pascalCase()}}Cubit(),
12+
child: _{{name.pascalCase()}}ContentScreen(),
13+
);
14+
}
15+
16+
class _{{name.pascalCase()}}ContentScreen extends StatelessWidget {
17+
@override
18+
Widget build(BuildContext context) => Container();
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
part of '{{name.snakeCase()}}_cubit.dart';
2+
3+
@freezed
4+
class {{name.pascalCase()}}State with _${{name.pascalCase()}}State {
5+
const factory {{name.pascalCase()}}State.state() = _{{name.pascalCase()}}State;
6+
}

bricks/xl_cubit_screen/brick.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: xl_cubit_screen
2+
description: A screen which uses Cubit for state management, following Xmartlabs' standards.
3+
4+
version: 0.1.0+1
5+
6+
environment:
7+
mason: ">=0.1.0-dev.26 <0.1.0"
8+
9+
vars:
10+
name:
11+
type: string
12+
description: Your screen/feature name
13+
default: xl
14+
prompt: What is your screen name?

0 commit comments

Comments
 (0)