Skip to content

Instantly share code, notes, and snippets.

@AndresR173
Last active May 7, 2021 17:48
Show Gist options
  • Save AndresR173/80deba2bee0580e86de3ba8ec38fe2fd to your computer and use it in GitHub Desktop.
Save AndresR173/80deba2bee0580e86de3ba8ec38fe2fd to your computer and use it in GitHub Desktop.
VS Code - Dart Code Snippets
{
"triple_a_test": {
"prefix": "aaa",
"description": "AAA test",
"body": [
"test(",
"\t'should $1',",
"\t() async {",
"\t\t// arrange",
"\t\t$2",
"\t\t// act",
"\t\t$3",
"\t\t// assert",
"\t\t$4",
"\t},",
");"
]
},
"MobX Store": {
"prefix": "mobx",
"body": [
"import 'package:mobx/mobx.dart';",
"part '${TM_FILENAME_BASE/(.*)/${1:/downcase}/}.g.dart';",
"",
"class $1Store = _$1Store with _$$1Store;",
"",
"abstract class _$1Store with Store {",
"\t${0}",
"}"
]
},
"MobX Observer": {
"prefix": "obs",
"body": [
"Observer(builder: (_) {",
" return Container(${0});",
"},",
")"
],
"description": "Create Widget Observer"
},
"Freezed Data Class": {
"prefix": "freezed",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '${TM_FILENAME_BASE}.g.dart';",
"part '${TM_FILENAME_BASE}.freezed.dart';",
"",
"@freezed",
"abstract class ${1:DataClass} with _$${1:DataClass}{",
"\t@JsonSerializable(fieldRename: FieldRename.snake)",
"\tconst factory ${1:DataClass}({${2}}) = _${1:DataClass};",
"",
"factory ${1}.fromJson(Map<String, dynamic> json) => _$${1}FromJson(json);",
"}",
],
"description": "Freezed Data Class"
},
"Freezed Union": {
"prefix": "funion",
"body": [
"@freezed",
"abstract class ${1:Union} with _$${1:Union}{",
" const factory ${1:Union}.${2}(${4}) = ${3};",
"}"
],
"description": "Freezed Union"
},
"From JSON": {
"prefix": "fromJson",
"body": [
"factory ${1}.fromJson(Map<String, dynamic> json) => _$${1}FromJson(json);"
],
"description": "From JSON"
},
"SizedBox": {
"prefix": "sbox",
"body": [
"const SizedBox(height: ${1}),"
],
"description": "SizedBox"
},
"Now": {
"prefix": "now",
"body": [
"DateTime.now()"
],
"description": "Current date"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment