Created
May 12, 2023 16:09
-
-
Save YumNumm/77fd7d6df0609963afab7e2973d05fe9 to your computer and use it in GitHub Desktop.
FreezedとJsonEnumのVSCode code-snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"Freezed class with import": { | |
"prefix": "frzclass", | |
"description": "Create a Freezed class", | |
"body": [ | |
"import 'package:freezed_annotation/freezed_annotation.dart';", | |
"part '${TM_FILENAME_BASE}.freezed.dart';", | |
"part '${TM_FILENAME_BASE}.g.dart';", | |
"", | |
"@freezed", | |
"class ${1:DataClass} with _$${1:DataClass} {", | |
"\tconst factory ${1:DataClass}({", | |
"\t\t@Default(0) int counter, // Add your fields here", | |
"\t}) = _${1:DataClass};", | |
"\n", | |
"\tfactory ${1:DataClass}.fromJson(Map<String, dynamic> json) =>", | |
"\t\t_$${1:DataClass}FromJson(json);", | |
"}" | |
] | |
}, | |
"Freezed class without import ": { | |
"prefix": "frz", | |
"description": "Create a Freezed class without import", | |
"body": [ | |
"@freezed", | |
"class ${1:DataClass} with _$${1:DataClass} {", | |
"\tconst factory ${1:DataClass}({", | |
"\t\t@Default(0) int counter, // Add your fields here", | |
"\t}) = _${1:DataClass};", | |
"", | |
"\tfactory ${1:DataClass}.fromJson(Map<String, dynamic> json) =>", | |
"\t\t\t_$${1:DataClass}FromJson(json);", | |
"}", | |
"" | |
] | |
}, | |
"JsonEnum": { | |
"prefix": "jsonEnum", | |
"description": "Create a JsonEnum", | |
"body": [ | |
"@JsonEnum(valueField: '${2:ValueField}')", | |
"enum ${1:Type} {", | |
"\tsample('exmple');", | |
"", | |
"\tconst ${1:Type}(this.${2:ValueField});", | |
"\tfinal String ${2:ValueField};", | |
"}" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment