-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode_snippets.json
157 lines (146 loc) · 4.76 KB
/
vscode_snippets.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{
"Create a Flutter Mediator Controller Function": {
"prefix": "controller",
"body": [
"Widget $1Controller() {",
" return Controller<${2:Model}>(",
" create: (context, model) => ElevatedButton(",
" child: const Text('$3'),",
" onPressed: () => model.${4:modelVar},",
" ),",
" );",
"}",
""
],
"description": "Create a Flutter Mediator Controller Function"
},
"Create a Flutter Mediator Subscriber Function with Aspect": {
"prefix": "subscriber",
"body": [
"Widget $1Subscriber() {",
" return '$2'.subModel<${3:Model}>((context, model) {",
" return Text('$4 ${model.${5:modelVar}}');",
" });",
"}"
],
"description": "Create a Flutter Mediator Subscriber Function with Aspect"
},
"Create a Flutter Mediator Subscriber Function with RX Auto Aspect": {
"prefix": "rxfun",
"body": [
"Widget $1Subscriber() {",
" return rxSub<${2:Model}>((context, model) {",
" return Text('$3 ${model.${4:rxVar}}');",
" });",
"}"
],
"description": "Create a Flutter Mediator Subscriber Function with RX Auto Aspect"
},
"Create a Flutter Mediator Subscriber with Aspect": {
"prefix": "submodel",
"body": [
"'$1'.subModel<${2:Model}>((context, model) {",
" return Text('$3 ${model.${4:modelVar}}');",
"},)$0"
],
"description": "Create a Flutter Mediator Subscriber with Aspect"
},
"Create a Flutter Mediator Subscriber with RX Auto Aspect": {
"prefix": "rxsub",
"body": [
"rxSub<${1:Model}>((context, model) {",
" return Text('$2 ${model.${3:rxVar}}');",
"},)$0"
],
"description": "Create a Flutter Mediator Subscriber with RX Auto Aspect"
},
"Get the Model of Flutter Mediator": {
"prefix": "getmodel",
"body": [
"Host.model<${1:Model}>()$0"
],
"description": "Get the Model of Flutter Mediator"
},
"Add a Creator to the Subscriber Map of the Model": {
"prefix": "addsub",
"body": [
"addSub(${1:key}, (context, model) {",
" $2",
"});$0"
],
"description": "Add a Creator to the Subscriber Map of the Model"
},
"Add a Creator to the Controller Map of the Model": {
"prefix": "addcon",
"body": [
"addCon(${1:key}, (context, model) {",
" $2",
"});$0"
],
"description": "Add a Creator to the Controller Map of the Model"
},
"Create a Subscriber Widget from the View Map of the Model": {
"prefix": "pubsub",
"body": [
"Pub.sub<${1:model}>('${2:key}'),$0"
],
"description": "Create a Subscriber Widget from the View Map of the Model"
},
"Create a Controller Widget from the View Map of the Model": {
"prefix": "pubcon",
"body": [
"Pub.controller<${1:model}>('${2:key}'),$0"
],
"description": "Create a Widget from the View Map of the Model"
},
"Generate a Model Boilerplate Code of Flutter Mediator": {
"prefix": "mmodel",
"body": [
"import 'package:flutter/widgets.dart';",
"import 'package:flutter_mediator/mediator.dart';",
"",
"class ${1:Model} extends Pub {",
" //* member variables",
" var foo = 0.rx;",
"",
" //* controller function",
" void increaseFoo() => foo++;",
"",
" //* View Map:",
" void addSub(Object o, CreatorFn<${1:Model}> sub) => regSub<${1:Model}>(o, sub);",
" void addCon(Object o, CreatorFn<${1:Model}> con) => regCon<${1:Model}>(o, con);",
"",
" @override",
" void init() {",
" addSub('', (context, model) {",
" // return Text('foo is ${model.foo}');",
" });",
"",
" addCon('', (context, model) {",
" // return ElevatedButton(child: const Text('Update foo'),",
" // onPressed: () => model.increaseFoo(),);",
" });",
"",
" super.init();",
" }",
"}",
"",
"//* Model extension",
"${1:Model} get${1:Model}(BuildContext context) => Host.model<${1:Model}>();",
"",
"Subscriber<${1:Model}> sub${1:Model}(CreatorFn<${1:Model}> create,",
" {Key? key, Object? aspects}) {",
" return Subscriber<${1:Model}>(key: key, aspects: aspects, create: create);",
"}",
"",
"extension ${1:Model}ExtT<T> on T {",
" Subscriber<${1:Model}> sub${1:Model}(CreatorFn<${1:Model}> create, {Key? key}) {",
" return Subscriber<${1:Model}>(key: key, aspects: this, create: create);",
" }",
"}",
""
],
"description": "Generate a Model Boilerplate Code of Flutter Mediator"
}
// },
}