Last active
October 2, 2023 09:00
-
-
Save adryanev/3fb44a7bec6b7d2728804da13ac12692 to your computer and use it in GitHub Desktop.
Flutter VSCode Snippet
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
{ | |
// 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" | |
// } | |
"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" | |
}, | |
"Basic test scaffolding": { | |
"prefix": "t_scaffold", | |
"body": [ | |
"import 'package:flutter_test/flutter_test.dart';", | |
"", | |
"void main() {", | |
" late ${1:ClassName} systemUnderTest;", | |
"", | |
" setUp(() {", | |
" systemUnderTest = ${1:ClassName}();", | |
" });", | |
"", | |
" group('', () {});", | |
"}", | |
"" | |
], | |
"description": "Basic test scaffolding" | |
}, | |
"Test following the Arrange-Act-Assert pattern": { | |
"prefix": "aaaTest", | |
"body": [ | |
"test(", | |
" '$1',", | |
" () async {", | |
" ", | |
" // arrange", | |
" $2", | |
" // act", | |
" $3", | |
" // assert", | |
" $4", | |
" },", | |
");" | |
], | |
"description": "Test following the Arrange-Act-Assert pattern" | |
}, | |
"Create from domain factory": { | |
"prefix": "fromDomain", | |
"body": [ | |
"factory ${1:ClassName}.fromDomain(${2:ClassName} form) => ${1:ClassName}($3);", | |
], | |
"description": "Create from domain factory with domain form as parameters." | |
}, | |
"Create from json factory": { | |
"prefix": "fromJson", | |
"body": [ | |
"factory ${1:ClassName}.fromJson(Map<String, dynamic> json) => _$${1:ClassName}FromJson(json);" | |
] | |
}, | |
"Create to json factory": { | |
"prefix": "toJson", | |
"body": [ | |
"Map<String, dynamic> toJson() => _$${1:ClassName}ToJson(this);" | |
] | |
}, | |
"Create toDomain() extension": { | |
"prefix": "toDomain", | |
"body": [ | |
"extension ${1:DtoClass}X on ${1:DtoClass} {", | |
" ${2:DomainClass} toDomain() => ${2:DomainClass}();", | |
"}", | |
], | |
"description": "Create from domain factory with domain form as parameters." | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment