Last active
June 28, 2023 14:03
-
-
Save AdelDaniel/1208c507685c6df5e166bd30f5f685e0 to your computer and use it in GitHub Desktop.
Snippet, I used in vs-code for dart programming language and flutter
This file contains hidden or 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
| { | |
| // "prefix": "scs": "static const String" | |
| // "prefix": "bstl": "create BaseStatelessWidget" | |
| // "prefix": "bstf": "create BaseStatefulWidget" | |
| // "prefix": "onbloc": "create on Method for bloc" | |
| // "prefix": "statebloc": "create State class for bloc without props" | |
| // "prefix": "stateblocprop": "create State class for bloc And props": | |
| // "prefix": "eventbloc": "create event class for bloc without props" | |
| // "prefix": "eventblocprop": "create event class for bloc And props": | |
| // "prefix": "staticbloc": "create event class for bloc And props": | |
| // "prefix": "text": "create Text Widget with style": | |
| // "prefix": "t_scaffold": "Basic test scaffolding" | |
| // "prefix": "aaaTest": "Test following the Arrange-Act-Assert pattern", | |
| // "prefix": "SizedBoxShrink", | |
| // 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" | |
| // } | |
| "static const String": { | |
| "prefix": "scs", | |
| "body": ["static const String $1 = \"$1\";"], | |
| "description": "Write static const String " | |
| }, | |
| "create BaseStatelessWidget": { | |
| "prefix": "bstl", | |
| "body": [ | |
| "import 'package:flutter/material.dart';", | |
| "", | |
| "class $1 extends BaseStatelessWidget {", | |
| " const $1({super.key});", | |
| "", | |
| " @override", | |
| " Widget baseBuild(BuildContext context) {", | |
| " return $2Container();", | |
| " }", | |
| "}" | |
| ], | |
| "description": "create BaseStatelessWidget" | |
| }, | |
| "create BaseStatefulWidget": { | |
| "prefix": "bstf", | |
| "body": [ | |
| "import 'package:flutter/material.dart';", | |
| "", | |
| "class $1 extends BaseStatefulWidget {", | |
| " const $1({super.key});", | |
| "", | |
| " @override", | |
| " BaseState<$1> baseCreateState() => _$1State();", | |
| "}", | |
| "", | |
| "class _$1State extends BaseState<$1> {", | |
| " @override", | |
| " Widget baseBuild(BuildContext context) {", | |
| " \treturn $2Container();", | |
| " }", | |
| "}" | |
| ], | |
| "description": "create BaseStatefulWidget" | |
| }, | |
| "create on Method for bloc": { | |
| "prefix": "onbloc", | |
| "body": [ | |
| "on<$1>(_on$1);", | |
| "", | |
| "", | |
| "FutureOr<void> _on$1(", | |
| " $1 event,", | |
| " Emitter<$2> emit,", | |
| ") {", | |
| " emit($3);", | |
| "}", | |
| "" | |
| ], | |
| "description": "create on Method for bloc" | |
| }, | |
| "create State class for bloc without props": { | |
| "prefix": "statebloc", | |
| "body": ["class $1State extends $2 {", "\tconst $1State();", "", "}"], | |
| "description": "create State class for bloc without props" | |
| }, | |
| "create State class for bloc And props": { | |
| "prefix": "stateblocprop", | |
| "body": [ | |
| "class $1State extends $2 {", | |
| "\tconst $1State();", | |
| "", | |
| "\t@override", | |
| "\tList<Object> get props => [];", | |
| "}" | |
| ], | |
| "description": "create State class for bloc And props" | |
| }, | |
| "create event class for bloc without props": { | |
| "prefix": "eventbloc", | |
| "body": ["class $event extends $2 {", "\tconst $event();", "", "}"], | |
| "description": "create event class for bloc without props" | |
| }, | |
| "create event class for bloc And props": { | |
| "prefix": "eventblocprop", | |
| "body": [ | |
| "class $1event extends $2 {", | |
| "\tconst $1event();", | |
| "", | |
| "\t@override", | |
| "\tList<Object> get props => [];", | |
| "}" | |
| ], | |
| "description": "create event class for bloc And props" | |
| }, | |
| "create static $1 bloc(BuildContext context)=> context.read<$1>();": { | |
| "prefix": "staticbloc", | |
| "body": ["static $1 bloc(BuildContext context) => context.read<$1>();"], | |
| "description": "create static $1 bloc(BuildContext context)=> context.read<$1>();" | |
| }, | |
| "create abstract class $1 implements Equatable": { | |
| "prefix": "ac", | |
| "body": [ | |
| "import 'package:equatable/equatable.dart';", | |
| "", | |
| "abstract class $1 implements Equatable {", | |
| "\tconst $1();", | |
| "}" | |
| ], | |
| "description": "create abstract class $1 implements Equatable" | |
| }, | |
| "create Text Widget with style": { | |
| "prefix": "text", | |
| "body": [ | |
| "Text(", | |
| " $1,", | |
| " style: const TextStyle(", | |
| " fontSize: $2,", | |
| " fontWeight: FontWeight.w$3,", | |
| " color: ConstColors.$4),", | |
| ")," | |
| ], | |
| "description": "create Text Widget with style" | |
| }, | |
| "Basic test scaffolding": { | |
| "prefix": "t_scaffold", | |
| "body": [ | |
| "import 'package:flutter_test/flutter_test.dart';", | |
| "", | |
| "void main() {", | |
| " late ${1:ClassName} sut;", | |
| "", | |
| " setUp(() {", | |
| " sut = ${1:ClassName}();", | |
| " });", | |
| "", | |
| " group('', () {});", | |
| "}", | |
| "" | |
| ], | |
| "description": "Basic test scaffolding" | |
| }, | |
| "Test following the Arrange-Act-Assert pattern": { | |
| "prefix": "aaaTest", | |
| "body": ["test(", " \"$1\",", " () async {", " $2", " },", ");"], | |
| "description": "Test following the Arrange-Act-Assert pattern" | |
| }, | |
| "Flutter widget test boilerplate": { | |
| "prefix": "wTest", | |
| "body": [ | |
| "testWidgets(", | |
| " \"$1\",", | |
| " (WidgetTester tester) async {$2},", | |
| ");" | |
| ], | |
| "description": "Flutter widget test boilerplate" | |
| }, | |
| "const Sized box Shrink": { | |
| "prefix": "SizedBoxShrink", | |
| "body": [ | |
| "const SizedBox.shrink();", | |
| ], | |
| "description": "const SizedBox.shrink()" | |
| } | |
| } |
Author
Author
Add new 7 Snippet:
- "bstl": "create BaseStatelessWidget"
- "bstf": "create BaseStatefulWidget"
- "onbloc": "create on Method for bloc"
- "statebloc": "create State class for bloc without props"
- "stateblocprop": "create State class for bloc And props":
- "eventbloc": "create event class for bloc without props"
- "eventblocprop": "create event class for bloc And props":
Author
Add new Snippet:
- "text": "create Text Widget with style":
Author
Add
- "prefix": "SizedBoxShrink"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add asc: