Skip to content

Instantly share code, notes, and snippets.

@orestesgaolin
Created March 19, 2020 15:57
Show Gist options
  • Save orestesgaolin/715bda4097ebacdfeb624726370ea2e6 to your computer and use it in GitHub Desktop.
Save orestesgaolin/715bda4097ebacdfeb624726370ea2e6 to your computer and use it in GitHub Desktop.
{
// Place your snippets for dart here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Generate json_serializable methods": {
"prefix": "json",
"body": [
" factory $1.fromJson(Map<String, dynamic> json) =>",
"_$$1FromJson(json);",
"Map<String, dynamic> toJson() => _$$1ToJson(this);"
],
},
"Generate json_serializable class": {
"prefix": "jsoncl",
"body": [
"@JsonSerializable(",
"nullable: false,",
"explicitToJson: true,",
"anyMap: true,",
")",
"class $1 {",
"$1();",
" factory $1.fromJson(Map<String, dynamic> json) =>",
"_$$1FromJson(json);",
"Map<String, dynamic> toJson() => _$$1ToJson(this);",
"}"
],
},
"Generate freezed class": {
"prefix": "freezed",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '$1.freezed.dart';",
"",
"@freezed",
"abstract class $2 with _$$2 {",
" factory $2() = _$2;",
"}"
]
},
"Generate freezed class with json_serializable": {
"prefix": "freezedj",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '$1.freezed.dart';",
"part '$1.g.dart';",
"",
"@freezed",
"abstract class $2 with _$$2 {",
" factory $2() = _$2;",
"",
" factory $2.fromJson(Map<String, dynamic> json) => _$$2FromJson(json);",
"}"
]
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment