Created
August 12, 2023 14:00
-
-
Save saileshbro/f446aa6839a1391d28322ae1b8e6499a to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
"Freezed model Json": { | |
"prefix": "frzjs", | |
"scope": "dart", | |
"isFileTemplate": true, | |
"body": [ | |
"import 'package:flutter/foundation.dart';", | |
"import 'package:freezed_annotation/freezed_annotation.dart';", | |
"", | |
"part '${TM_FILENAME_BASE/(.*)/${1:/lowercase}/g}.freezed.dart';", | |
"part '${TM_FILENAME_BASE/(.*)/${1:/lowercase}/g}.g.dart';", | |
"", | |
"@freezed", | |
"class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} with _$${1} {", | |
" const factory ${1}({", | |
" required ${2:String id},", | |
" }) = _${1};", | |
"", | |
" factory ${1}.fromJson(Map<String, dynamic> json) => ", | |
" _$${1}FromJson(json);", | |
"}", | |
"", | |
"${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} deserialize${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}(Map<String, dynamic> json) =>", | |
" ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}.fromJson(json);", | |
"List<${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}> deserialize${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}List(List<Map<String, dynamic>> json) =>", | |
" json.map(${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}.fromJson).toList();", | |
"Map<String, dynamic> serialize${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}(${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} object) => object.toJson();", | |
"List<Map<String, dynamic>> serialize${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}List(List<${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}}> objects) =>", | |
" objects.map((e) => e.toJson()).toList();", | |
"", | |
], | |
"description": "Freezed model with Json" | |
}, | |
} |
Author
saileshbro
commented
Aug 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment