New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Suggestion] VS Code snippet to generate basic layout of freezed model class #85
Comments
I think @ResoCoder did |
Ok, I tried on my own and this is my proposal: "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;",
"}"
]
} |
Here it is: |
Here are all the snippets which you may find useful when working with Freezed. "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",
"abstract class ${1:DataClass} with _$${1:DataClass}{",
" const factory ${1:DataClass}(${2}) = _${1:DataClass};",
"}"
],
"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"
},
"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"
}, |
This comment has been minimized.
This comment has been minimized.
Closing this since there are quite a few solutions and I don't want to maintain these myself. |
Here is an updated template for Android Studio/Intelli, in complement to the one of @knaeckeKami it will:
To add this template:
PS: thanks for the plugin ! |
It would be useful to have a VS Code snippet to generate basic layout of the model class. It's easy to forget about some parts such as
part
orabstract
.Did anyone create such snippet? I would love to use one.
The text was updated successfully, but these errors were encountered: