-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflutter.code-snippets
112 lines (108 loc) · 2.88 KB
/
flutter.code-snippets
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
/*
Windows %APPDATA%\Code\User\snippets\(language).json
Mac $HOME/Library/Application Support/Code/User/snippets/(language).json
Linux $HOME/.config/Code/User/snippets/(language).json
*/
{
// #region Debug
"Debug Print": {
"scope": "dart",
"prefix": "c_debug_print",
"body": "print(\"[C_${1:1}]: ${$2}\");",
"description": "Debug Print"
},
"Debug Text": {
"scope": "dart",
"prefix": "c_debug_text",
"body": "CText(\"[C_${1:1}]: ${$2}\"),",
"description": "Debug Text"
},
// #endregion
// #region Notifier
"Build ValueListenableBuilder": {
"scope": "dart",
"prefix": "c_notifier_builder",
"body": [
"ValueListenableBuilder<${1:dynamic}>(",
" valueListenable: $2,",
" builder: (_, value, __) {",
" return ${3:Text(value.toString())};",
" },",
"),"
],
"description": "Build ValueListenableBuilder"
},
// #endregion
// #region Bloc
"Build Bloc Builder": {
"scope": "dart",
"prefix": "c_bloc_builder",
"body": [
"StreamBuilder<${1:String}>(",
" stream: ${2:BlocName}.stream,",
" initialData: ${2:BlocName}.data,",
" builder: (context, snapshot) {",
" if(!snapshot.hasData || snapshot.data == null){",
" return const SizedBox.shrink();",
" }",
" return Text(snapshot.data.toString());",
" },",
"),"
],
"description": "Build Bloc Builder"
},
// #endregion
// #region Create
"Create Singleton": {
"scope": "dart",
"prefix": "c_create_singleton",
"body": [
"static final ${1:ClassName} _instance = $1._internal();",
"factory $1() => _instance;",
"$1._internal();"
],
"description": "Create Singleton"
},
"Create Screen": {
"scope": "dart",
"prefix": "c_create_screen",
"body": [
"// ignore_for_file: use_key_in_widget_constructors",
"",
"import 'package:flutter/material.dart';",
"",
"class ${1:ClassName}Screen extends StatelessWidget {",
" static const route = '$1Screen';",
"",
" @override",
" Widget build(BuildContext context) {",
" return Scaffold(",
" appBar: AppBar(centerTitle: true, title: const Text(route)),",
" body: Column(",
" children: [",
" body(route),",
" ],",
" ),",
" );",
" }",
"",
" Widget body(String text) {",
" return Center(child: Text(text));",
" }",
"}",
""
],
"description": "Create Screen"
},
"Create DataNotifier": {
"scope": "dart",
"prefix": "c_create_data_notifier",
"body": [
"DataNotifier<${1:ModelName}>? _${2:dataName}Notifier;",
"DataNotifier<$1> get $2Notifier =>",
" _$2Notifier ??= DataNotifier<$1>(${3:InitialValue});"
],
"description": "Create DataNotifier"
}
// #endregion
}