Skip to content

Instantly share code, notes, and snippets.

@debkanchan
Created February 12, 2021 16:50
Show Gist options
  • Save debkanchan/9c699b1067425e86344bc2fd87831fb5 to your computer and use it in GitHub Desktop.
Save debkanchan/9c699b1067425e86344bc2fd87831fb5 to your computer and use it in GitHub Desktop.
Flutter/Dart Freezed Snippets
{
"Freezed Class": {
"prefix": "frz",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '${1/(.*)/${1:/downcase}/}.freezed.dart';",
"part '${1/(.*)/${1:/downcase}/}.g.dart'",
"",
"@freezed",
"abstract class ${1:Classname} with _$${1:Classname} {",
"\tfactory ${1:Classname}(classProperties) = _${1:Classname};",
"}"
],
"description": "Create new immutable data type"
},
"Freezed Serializable Class": {
"prefix": "frzs",
"body": [
"import 'package:freezed_annotation/freezed_annotation.dart';",
"",
"part '${1/(.*)/${1:/downcase}/}.freezed.dart';",
"part '${1/(.*)/${1:/downcase}/}.g.dart';",
"",
"@freezed",
"abstract class ${1:Classname} implements _$${1:Classname} {",
"\tfactory ${1:Classname}(${2:properties}) = _${1:Classname};",
"\tfactory ${1:Classname}.fromJson(Map<String, dynamic> json) => _$${1:Classname}FromJson(json);",
"}"
],
"description": "Create new immutable JSON serilizable data type"
}
}
@debkanchan
Copy link
Author

Make sure to hit Tab after writing classname for classname to filename snippet converter to work correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment