-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathsnippets.json
507 lines (507 loc) · 17.2 KB
/
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
{
"Stateless Widget": {
"prefix": "statelessW",
"body": [
"class ${1:name} extends StatelessWidget {",
" const ${1:name}({super.key});\n",
" @override",
" Widget build(BuildContext context) {",
" return Container();",
" }",
"}"
],
"description": "Create a Stateless widget"
},
"Stateful Widget": {
"prefix": "statefulW",
"body": [
"class ${1:name} extends StatefulWidget {",
" const ${1:name}({super.key});\n",
" @override",
" State<${1:index}> createState() => _${1:WidgetName}State();",
"}\n",
"class _${1:index}State extends State<${1:index}> {",
" @override",
" Widget build(BuildContext context) {",
" return Container();",
" }",
"}"
],
"description": "Create a Stateful widget"
},
"Build Method": {
"prefix": "build",
"body": [
"@override",
"Widget build(BuildContext context) {",
" return ${0:};",
"}"
],
"description": "Describes the part of the user interface represented by this widget."
},
"Custom Painter ": {
"prefix": "customPainter",
"body": [
"class ${0:name}Painter extends CustomPainter {",
"",
" @override",
" void paint(Canvas canvas, Size size) {",
" }",
"",
" @override",
" bool shouldRepaint(${0:name}Painter oldDelegate) => false;",
"",
" @override",
" bool shouldRebuildSemantics(${0:name}Painter oldDelegate) => false;",
"}"
],
"description": "Used for creating custom paint"
},
"Custom Clipper ": {
"prefix": "customClipper",
"body": [
"class ${0:name}Clipper extends CustomClipper<Path> {",
"",
" @override",
" Path getClip(Size size) {",
" }",
"",
" @override",
" bool shouldReclip(CustomClipper<Path> oldClipper) => false;",
"}"
],
"description": "Used for creating custom shapes"
},
"InitState ": {
"prefix": "initS",
"body": [
"@override",
"void initState() {",
" super.initState();",
" ${0:}",
"}"
],
"description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates."
},
"Dispose": {
"prefix": "dis",
"body": [
"@override",
"void dispose() {",
" ${0:}",
" super.dispose();",
"}"
],
"description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again."
},
"Reassemble": {
"prefix": "reassemble",
"body": [
"@override",
"void reassemble(){",
" super.reassemble();",
" ${0:}",
"}"
],
"description": "Called whenever the application is reassembled during debugging, for example during hot reload."
},
"didChangeDependencies": {
"prefix": "didChangeD",
"body": [
"@override",
"void didChangeDependencies() {",
" super.didChangeDependencies();",
" ${0:}",
"}"
],
"description": "Called when a dependency of this State object changes"
},
"didUpdateWidget": {
"prefix": "didUpdateW",
"body": [
"@override",
"void didUpdateWidget (${1:Type} ${2:oldWidget}) {",
" super.didUpdateWidget(${2:oldWidget});",
" ${0:}",
"}"
],
"description": "Called whenever the widget configuration changes."
},
"ListView.Builder": {
"prefix": "listViewB",
"body": [
"ListView.builder(",
" itemCount: ${1:1},",
" itemBuilder: (BuildContext context, int index) {",
" return ${2:};",
" },",
"),"
],
"description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent."
},
"ListView.Separated": {
"prefix": "listViewS",
"body": [
"ListView.separated(",
" itemCount: ${1:1},",
" separatorBuilder: (BuildContext context, int index) {",
" return ${2:};",
" },",
" itemBuilder: (BuildContext context, int index) {",
" return ${3:};",
" },",
"),"
],
"description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'."
},
"GridView.Builder": {
"prefix": "gridViewB",
"body": [
"GridView.builder(",
" gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(",
" crossAxisCount: ${1:2},",
" ),",
" itemCount: ${2:2},",
" itemBuilder: (BuildContext context, int index) {",
" return ${3:};",
" },",
"),"
],
"description": "Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null `itemCount` improves the ability of the [GridView] to estimate the maximum scroll extent."
},
"GridView.Count": {
"prefix": "gridViewC",
"body": [
"GridView.count(",
" crossAxisSpacing: ${1:1},",
" mainAxisSpacing: ${2:2},",
" crossAxisCount: ${3:2},",
" children: <Widget> [",
" ${4:}",
" ],",
"),"
],
"description": "Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis."
},
"GridView.Extent": {
"prefix": "gridViewE",
"body": [
"GridView.extent(",
" maxCrossAxisExtent: ${1:2},",
" children: <Widget> [",
" ${2:}",
" ],",
"),"
],
"description": "Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent."
},
"Custom Scroll View": {
"prefix": "customScrollV",
"body": [
"CustomScrollView(",
" slivers: <Widget>[",
" ${0:}",
" ],",
"),"
],
"description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null."
},
"Stream Builder": {
"prefix": "streamBldr",
"body": [
"StreamBuilder(",
" stream: ${1:stream},",
" initialData: ${2:initialData},",
" builder: (BuildContext context, AsyncSnapshot snapshot) {",
" return Container(",
" child: ${3:child},",
" );",
" },",
"),"
],
"description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`"
},
"Animated Builder": {
"prefix": "animatedBldr",
"body": [
"AnimatedBuilder(",
" animation: ${1:animation},",
" child: ${2:child},",
" builder: (BuildContext context, Widget? child) {",
" return ${3:};",
" },",
"),"
],
"description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder`"
},
"Stateful Builder": {
"prefix": "statefulBldr",
"body": [
"StatefulBuilder(",
" builder: (BuildContext context, setState) {",
" return ${0:};",
" },",
"),"
],
"description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree."
},
"Orientation Builder": {
"prefix": "orientationBldr",
"body": [
"OrientationBuilder(",
" builder: (BuildContext context, Orientation orientation) {",
" return Container(",
" child: ${3:child},",
" );",
" },",
"),"
],
"description": "Creates a builder which allows for the orientation of the device to be specified and referenced"
},
"Layout Builder": {
"prefix": "layoutBldr",
"body": [
"LayoutBuilder(",
" builder: (BuildContext context, BoxConstraints constraints) {",
" return ${0:};",
" },",
"),"
],
"description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints."
},
"Single Child ScrollView": {
"prefix": "singleChildSV",
"body": [
"SingleChildScrollView(",
" controller: ${1:controller,}",
" child: Column(",
" ${0:}",
" ),",
"),"
],
"description": "Creates a scroll view with a single child"
},
"Future Builder": {
"prefix": "futureBldr",
"body": [
"FutureBuilder(",
" future: ${1:Future},",
" initialData: ${2:InitialData},",
" builder: (BuildContext context, AsyncSnapshot snapshot) {",
" return ${3:};",
" },",
"),"
],
"description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future."
},
"No Such Method": {
"prefix": "nosm",
"body": [
"@override",
"dynamic noSuchMethod(Invocation invocation) {",
" ${1:}",
"}"
],
"description": "This method is invoked when a non-existent method or property is accessed."
},
"Inherited Widget": {
"prefix": "inheritedW",
"body": [
"class ${1:Name} extends InheritedWidget {",
" const ${1:Name}({super.key, required this.child}) : super(child: child);",
"",
" final Widget child;",
"",
" static ${1:Name}? of(BuildContext context) {",
" return context.dependOnInheritedWidgetOfExactType<${1:Name}>();",
" }",
"",
" @override",
" bool updateShouldNotify(${1:Name} oldWidget) {",
" return ${2:true};",
" }",
"}"
],
"description": "Class used to propagate information down the widget tree"
},
"Mounted": {
"prefix": "mounted",
"body": [
"@override",
"bool get mounted {",
" ${0:}",
"}"
],
"description": "Whether this State object is currently in a tree."
},
"Sink": {
"prefix": "snk",
"body": [
"Sink<${1:type}> get ${2:name} => _${2:name}Controller.sink;",
"final _${2:name}Controller = StreamController<${1:type}>();"
],
"description": "A Sink is the input of a stream."
},
"Stream": {
"prefix": "strm",
"body": [
"Stream<${1:type}> get ${2:name} => _${2:name}Controller.stream;",
"final _${2:name}Controller = StreamController<${1:type}>();"
],
"description": "A source of asynchronous data events. A stream can be of any data type <T>"
},
"Subject": {
"prefix": "subj",
"body": [
"Stream<${1:type}> get ${2:name} => _${2:name}Subject.stream;",
"final _${2:name}Subject = BehaviorSubject<${1:type}>();"
],
"description": "A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream."
},
"toString": {
"prefix": "toStr",
"body": [
"@override",
"String toString() => ${1:toString}"
],
"description": "Returns a string representation of this object."
},
"debugPrint": {
"prefix": "debugP",
"body": [
"debugPrint(${1:statement});"
],
"description": "Prints a message to the console, which you can access using the flutter tool's `logs` command (flutter logs)."
},
"Material Package": {
"prefix": "importM",
"body": "import 'package:flutter/material.dart';",
"description": "Import flutter material package"
},
"Cupertino Package": {
"prefix": "importC",
"body": "import 'package:flutter/cupertino.dart';",
"description": "Import Flutter Cupertino package"
},
"flutter_test Package": {
"prefix": "importFT",
"body": "import 'package:flutter_test/flutter_test.dart';",
"description": "Import flutter_test package"
},
"app_localizations Package": {
"prefix": "importAL",
"body": "import 'package:flutter_gen/gen_l10n/app_localizations.dart';",
"description": "Import app_localizations package"
},
"Material App": {
"prefix": "mateapp",
"description": "Create a MaterialApp",
"body": [
"import 'package:flutter/material.dart';",
"",
"void main() => runApp(const MyApp());",
"",
"class MyApp extends StatelessWidget {",
" const MyApp({super.key});",
"",
" @override",
" Widget build(BuildContext context) {",
" return MaterialApp(",
" title: 'Material App',",
" home: Scaffold(",
" appBar: AppBar(",
" title: const Text('Material App Bar'),",
" ),",
" body: const Center(",
" child: Text('Hello World'),",
" ),",
" ),",
" );",
" }",
"}"
]
},
"Cupertino App": {
"prefix": "cupeapp",
"description": "Create a CupertinoApp",
"body": [
"import 'package:flutter/cupertino.dart';",
"",
"void main() => runApp(const MyApp());",
"",
"class MyApp extends StatelessWidget {",
" const MyApp({super.key});",
"",
" @override",
" Widget build(BuildContext context) {",
" return const CupertinoApp(",
" title: 'Cupertino App',",
" home: CupertinoPageScaffold(",
" navigationBar: CupertinoNavigationBar(",
" middle: Text('Cupertino App Bar'),",
" ),",
" child: Center(",
" child: Text('Hello World'),",
" ),",
" ),",
" );",
" }",
"}"
]
},
"Tween Animation Builder": {
"prefix": "tweenAnimationBuilder",
"body": [
"TweenAnimationBuilder(",
" duration: ${1:const Duration(),}",
" tween: ${2:Tween(),}",
" builder: (BuildContext context, ${3:dynamic} value, Widget? child) {",
" return ${4:Container();}",
" },",
"),"
],
"description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes."
},
"Value Listenable Builder": {
"prefix": "valueListenableBuilder",
"body": [
"ValueListenableBuilder(",
" valueListenable: ${1: null},",
" builder: (BuildContext context, ${2:dynamic} value, Widget? child) {",
" return ${3: Container();}",
" },",
"),"
],
"description": "Given a ValueListenable<T> and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes."
},
"Test": {
"prefix": "f-test",
"body": [
"test(",
" \"${1:test description}\",",
" () {},",
");"
],
"description": "Create a test function"
},
"Group": {
"prefix": "f-group",
"body": [
"group(",
" \"${1:group description}\",",
" () {},",
");"
],
"description": "Create a group test function"
},
"Test Widgets": {
"prefix": "f-testWidgets",
"body": [
"testWidgets(",
" \"${1:test description}\",",
" (WidgetTester tester) async {},",
");"
],
"description": "Create a testWidgets function"
}
}