Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flutter / Stacked snippets for productivity
{
"Freezed model": {
"prefix": "frz",
"body": [
"@freezed",
"class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} with _$${1} {",
" factory ${1}({",
" @required ${2:String id},",
" }) = _${1};",
"}"
],
"description": "Freezed model"
},
"Freezed model Json": {
"prefix": "frzjs",
"body": [
"@freezed",
"class ${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} with _$${1} {",
" factory ${1}({",
" @required ${2:String id},",
" }) = _${1};",
"",
"factory ${1}.fromJson(Map<String, dynamic> json) => ",
"_$${1}FromJson(json);",
"}"
],
"description": "Freezed model with Json"
},
"Stacked View": {
"prefix": "stkv",
"body": [
"import 'package:flutter/material.dart';",
"import 'package:stacked/stacked.dart';",
"",
"class ${1} extends StatelessWidget {",
" const ${1}({Key key}) : super(key: key);",
"",
" @override",
" Widget build(BuildContext context) {",
" return ViewModelBuilder<${1}Model>.reactive(",
" builder: (context, model, child) => Scaffold(),",
" viewModelBuilder: () => ${1}Model(),",
" );",
" }",
"}"
],
"description": "Stacked View"
},
"Stacked BaseViewModel": {
"prefix": "stkbvm",
"body": [
"import 'package:stacked/stacked.dart';",
"",
"class ${1}Model extends BaseViewModel {}",
],
"description": "Stacked BaseViewModel"
},
"Mock Registration": {
"prefix": "testr",
"body": [
"${1} getAndRegister${1}() {",
" _removeRegistrationIfExists<${1}>();",
" final service = Mock${1}();",
" locator.registerSingleton<${1}>(service);",
" return service;",
"}"
],
"description": "Creating a Mock Registration Function"
},
"Main Test Suite Setup": {
"prefix": "testm",
"body": [
"import 'package:flutter_test/flutter_test.dart';",
"",
"void main() {",
" group('${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} -', (){",
"",
" });",
"}"
],
"description": "Main Test Suite Setup"
},
"Main Test Suite Setup with Services": {
"prefix": "testmr",
"body": [
"import 'package:flutter_test/flutter_test.dart';",
"",
"void main() {",
" group('${1:${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}} -', (){",
" setUp(() => registerServices());",
" tearDown(() => unregisterServices());",
" });",
"}"
],
"description": "Main Test Suite Setup with Services"
},
"Test Group Setup": {
"prefix": "testg",
"description": "Creates a Test group with a test",
"body": [
"group('${1} -', () {",
" test('${2}', () {",
"",
" });",
"});",
]
},
"Single Test Setup": {
"prefix": "tests",
"description": "Creates a single test",
"body": [
" test('${1}', () {",
"",
" });",
]
},
}
@RodolfoSilva

This comment has been minimized.

Copy link

@RodolfoSilva RodolfoSilva commented Jun 13, 2020

Add this in each snippet to make the snippet available only when there is a dart or flutter scope.

"scope": "dart,flutter",
@FilledStacks

This comment has been minimized.

Copy link
Owner Author

@FilledStacks FilledStacks commented Jun 14, 2020

Thanks 👍

@KDCinfo

This comment has been minimized.

Copy link

@KDCinfo KDCinfo commented Nov 25, 2020

First, thank you for these snippets, and for everything you've provided to the flourishing world of prospering Flutter developers and aspiring mobile app architects. 👍

Add this in each snippet to make the snippet available only when there is a dart or flutter scope.

"scope": "dart,flutter",

The scope property gives me 7 warnings in the VS Code 'Problems' panel: Property scope is not allowed.

@manafire

This comment has been minimized.

Copy link

@manafire manafire commented Feb 22, 2021

I think the scope is only valid if you're adding the snippets globally. If you're adding them to dart.json they're already scoped and you'll get the warning (but they still work).

@FilledStacks

This comment has been minimized.

Copy link
Owner Author

@FilledStacks FilledStacks commented Feb 23, 2021

@manafire and @KDCinfo I've removed it.

@demolaf

This comment has been minimized.

Copy link

@demolaf demolaf commented Apr 17, 2021

Is it possible to use this in Android studio?

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