Skip to content

Instantly share code, notes, and snippets.

@2shrestha22
Last active July 31, 2022 21:08
Show Gist options
  • Save 2shrestha22/b7c8b9c22ba4c2c5f16695c70bb0868d to your computer and use it in GitHub Desktop.
Save 2shrestha22/b7c8b9c22ba4c2c5f16695c70bb0868d to your computer and use it in GitHub Desktop.
Freezed Snippet for VS Code. ctrl+shift+p - configure user snippet - add new global snippet - paste this
// by ResoCoder
// https://github.com/rrousselGit/freezed/issues/85#issuecomment-593908291
{
"Part statement": {
"prefix": "pts",
"body": [
"part '${TM_FILENAME_BASE}.g.dart';",
],
"description": "Creates a filled-in part statement"
},
"Part 'Freezed' statement": {
"prefix": "ptf",
"body": [
"part '${TM_FILENAME_BASE}.freezed.dart';",
],
"description": "Creates a filled-in freezed part statement"
},
"Freezed Data Class": {
"prefix": "fdataclass",
"body": [
"@freezed",
"class ${1:DataClass} with _$${1:DataClass}{",
" const factory ${1:DataClass}(${2}) = _${1:DataClass};",
"}"
],
"description": "Freezed Data Class"
},
"Freezed Union": {
"prefix": "funion",
"body": [
"@freezed",
"class ${1:Union} with _$${1:Union}{",
" const factory ${1:Union}.${2}(${4}) = ${3};",
"}"
],
"description": "Freezed Union"
},
"Freezed Union Case": {
"prefix": "funioncase",
"body": [
"const factory ${1:Union}.${2}(${4}) = ${3};"
],
"description": "Freezed Union Case"
},
"From JSON": {
"prefix": "fromJson",
"body": [
"factory ${1}.fromJson(Map<String, dynamic> json) => _$${1}FromJson(json);"
],
"description": "From JSON"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment