├── .gitignore ├── .vscodeignore ├── assets ├── flutter.png └── flutter-snippet-sample.gif ├── .gitattributes ├── CHANGELOG.md ├── .vscode └── launch.json ├── package.json ├── LICENSE ├── vsc-extension-quickstart.md ├── README.md └── snippets └── dart.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix 3 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /assets/flutter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alexisvt/flutter-snippets/HEAD/assets/flutter.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | 4 | -------------------------------------------------------------------------------- /assets/flutter-snippet-sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alexisvt/flutter-snippets/HEAD/assets/flutter-snippet-sample.gif -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "flutter-snippets" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | - Initial release -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ] 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter-snippets", 3 | "displayName": "Flutter Widget Snippets", 4 | "description": "A set of helpful widget snippets for day to day Flutter development", 5 | "version": "3.0.0", 6 | "license": "MIT", 7 | "publisher": "alexisvt", 8 | "engines": { 9 | "vscode": "^1.24.0" 10 | }, 11 | "icon": "assets/flutter.png", 12 | "categories": [ 13 | "Snippets" 14 | ], 15 | "contributes": { 16 | "snippets": [ 17 | { 18 | "language": "dart", 19 | "path": "./snippets/dart.json" 20 | } 21 | ] 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/Alexisvt/flutter-snippets.git" 26 | }, 27 | "bugs": { 28 | "url": "https://github.com/Alexisvt/flutter-snippets/issues", 29 | "email": "alexisvt@gmail.com" 30 | }, 31 | "keywords": [ 32 | "dart", 33 | "snippet", 34 | "flutter", 35 | "widgets" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 alexisvt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension. 5 | * `package.json` - this is the manifest file that defines the location of the snippet file 6 | and specifies the language of the snippets. 7 | * `snippets/snippets.json` - the file containing all snippets. 8 | 9 | ## Get up and running straight away 10 | * Press `F5` to open a new window with your extension loaded. 11 | * Create a new file with a file name suffix matching your language. 12 | * Verify that your snippets are proposed on intellisense. 13 | 14 | ## Make changes 15 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 16 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 17 | 18 | ## Install your extension 19 | * To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. 20 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ![snippets in action](assets/flutter-snippet-sample.gif) 4 | 5 | A set of helpful Flutter and Dart snippets for day to day Flutter development. 6 | 7 | ## Features 8 | 9 | Simply Flutter set of snippets 10 | 11 | I'm working hard to select all the day to day widgets, so wait for more!. 12 | 13 | ### Snippets 14 | 15 | ### Flutter related snippets 16 | 17 | | Snippet | Description | 18 | | ---------- | -------------------------------------------------------------------------------- | 19 | | `fstful` | StatefulWidget snippet. This is an alternative of `stful` | 20 | | `fstless` | StatelessWidget snippet. This is an alternative of `stless` | 21 | | `fscaff` | Scaffold widget snippet | 22 | | `fedgall` | EdgeInsets widget snippet with named constructor `all` | 23 | | `fedgonly` | EdgeInsets widget snippet with named constructor `only` | 24 | | `ftxt` | Text widget snippet | 25 | | `finitlf` | Flutter initState lifecycle method snippet | 26 | | `fic` | Flutter Icon widget snippet | 27 | | `fcont` | Flutter Container widget snippet | 28 | | `fcent` | Flutter Center widget snippet | 29 | | `frow` | Flutter Row widget snippet | 30 | | `fcol` | Flutter Column widget snippet | 31 | | `fex` | Expand widget snippet | 32 | | `fszbw` | SizedBox widget snippet with just width argument | 33 | | `fszbh` | SizedBox widget snippet with just height argument | 34 | | `fszb` | SizedBox widget with width and height arguments | 35 | | `fedgsym` | EdgeInsets widget with named constructor `symmetric` | 36 | | `fedgsymv` | EdgeInsets widget with named constructor `symmetric` with `vertical` parameter | 37 | | `fedgsymh` | EdgeInsets widget with named constructor `symmetric` with `horizontal` parameter | 38 | | `fimpmat` | Add material's package import statement | 39 | | `fstream` | Display a StreamBuilder widget | 40 | | `felbtn` | Flutter ElevatedButton snippet | 41 | 42 | ### Dart related snippets 43 | 44 | | Snippet | Description | 45 | | ---------- | -------------------------------------------------- | 46 | | `dvar` | Dart variable declaration using `var` | 47 | | `dfinal` | Dart variable declaration using `final` | 48 | | `dconst` | Dart variable declaration using `const` | 49 | | `dinvar` | Dart Public Instance variable snippet | 50 | | `dprinvar` | Dart Private instance variable snippet | 51 | | `dmt` | Dart public method snippet | 52 | | `dprmt` | Dart private method snippet | 53 | | `darr` | Dart public arrow function snippet | 54 | | `dprarr` | Dart private arrow function snippet | 55 | | `dopnctor` | Dart optional named parameters constructor snippet | 56 | | `dlist` | Dart `List` collection snippet | 57 | | `dmap` | Dart `Map` collection snippet | 58 | | `dset` | Dart `Set` collection snippet | 59 | | `dgetarr` | Dart arrow function getter snippet | 60 | | `dimpas` | Dart `import as` snippet | 61 | | `dimpshow` | Dart `import show` snippet | 62 | | `dimplazy` | Dart `import deffered as` snippet | 63 | | `dimphide` | Dart `import hide` snippet | 64 | | `dexhide` | Dart `export hide` snippet | 65 | | `dexshow` | Dart `export show` snippet | 66 | | `dconvert` | Dart `convert` lib import snippet | 67 | | `dimpmeta` | Add meta package import statement | 68 | | `dan` | Add a Dart anonymous function | 69 | | `dcla` | Add Dart Class snippet | 70 | | `dclae` | Add Dart Class snippet with extends keyword | 71 | 72 | ### Flutter Bloc pattern snippets 73 | 74 | | Snippet | Description | 75 | | ----------- | ----------------------------- | 76 | | `fblocprov` | Flutter bloc provider snippet | 77 | 78 | ## Release Notes 79 | 80 | ## 3.0.0 81 | 82 | - Features 83 | - put back `fstless` and `fstful` but this time these work differently, now the Widgets will be named base on the file name. 84 | - If you don't want this behavior you can use `stless` or `stful` instead. 85 | - make semicolon optional for `fscaff` snippet. 86 | - prepend `const` keyword to some widgets to avoid linter warnings. 87 | - add `felbtn` snippet. 88 | - add `dcla` Dart Class snippet. 89 | - add `dclae` Add Dart Class snippet with extends keyword. 90 | - Breaking Changes 91 | - `var` on `dvar` snippet is now optional, you can choose to use a type instead, and the semicolon was removed. 92 | - this open the possibility to use `dvar` for parameter declaration. 93 | 94 | ## 2.1.0 95 | 96 | - Features 97 | - add `fblocprov` bloc provider snippet. 98 | - add `dimpmeta`, which add meta package import statement. 99 | - add Dart anonymous function - `dan` . 100 | - remove from the Flutter related snippets `fstfulapp` and `fstless`. 101 | - use `stless` and `stful` instead, [these come with the official Flutter extension](https://flutter.dev/docs/development/tools/vs-code#snippets). 102 | 103 | ## 2.0.0 104 | 105 | - Features 106 | - remove `fstfulapp` and `fstless` since DartCode extension already has them. 107 | - add `fimpmat` snippet that add material package import statement. 108 | - add `fstream` snippet that display an StreamBuilder widget 109 | - replace body property value from `fscaff` snippet to a more generic value. 110 | - equal operator on `dfinal` and `dconst` now is optional 111 | - add `` generic type to `fcol` and `frow` snippets 112 | 113 | ### 1.1.0 114 | 115 | - Features: 116 | - add `dimpas`, `dimpshow`, `dimplazy`, `dimphide` import snippets. 117 | - add `dexhide` and `dexshow` export snippets. 118 | - add `dmt` public method snippets. 119 | - add `convert` lib import snippet. 120 | - add `dvar`,`dfinal` and `dconst` variable declaration snippets. 121 | - add `darr` and `dprarr` arrow function snippets. 122 | 123 | ### 1.0.0 124 | 125 | - Fixes: 126 | - add the material package import to fstless snippet. 127 | - Refactors: 128 | - change the type of `dinvar` and `dprinvar` to a more generic one (dynamic) and remove the initialization. 129 | - remove the semicolon to `dinvar` snippet to allow use case when we want to use it as a function parameter. 130 | - Docs: 131 | - organize the Flutter and the Dart snippets 132 | - change the render header to description 133 | - Features: 134 | - add Dart `List`, `Map` and `Set` collection snippets 135 | - add Dart arrow function getter snippet 136 | 137 | ### 0.0.3 138 | 139 | - Fixes 140 | - Typos 141 | - New snippets: 142 | - fedgsym - EdgeInsets widget with named constructor `symmetric` 143 | - fedgsymv - EdgeInsets widget with named constructor `symmetric` with `vertical` parameter 144 | - fedgsymh - EdgeInsets widget with named constructor `symmetric` with `horizontal` parameter 145 | - Special thanks to: 146 | - [Ajil Ooommen](https://github.com/ajilo297): Add fedgsym, fedgsymv, fedgsymh snippets. 147 | 148 | ### 0.0.2 149 | 150 | - New Snippets: 151 | - fex - Expand widget snippet 152 | - fszbw - SizedBox widget snippet with just width argument 153 | - fszbh - SizedBox widget snippet with just height argument 154 | - fszb - SizedBox widget with width and height arguments 155 | - fedgonly - EdgeInsets widget snippet with named constructor `only` 156 | - Renamed snippets: 157 | - fedgeiallw -> fedgall 158 | - froww -> frow 159 | - fcolw -> fcol 160 | - fcontw -> fcont 161 | - fcentw -> fcent 162 | - fwscaffoldw -> fscaff 163 | - fstlessw -> fstless 164 | - fstfulwapp -> fstfulapp 165 | - ftxtw -> ftxt 166 | - finitlfm -> finitlf 167 | - ficw - fic 168 | - Fixes: 169 | - path of the gif image 170 | 171 | ### 0.0.1 172 | 173 | Initial release 174 | -------------------------------------------------------------------------------- /snippets/dart.json: -------------------------------------------------------------------------------- 1 | { 2 | "Stateless widget snippet": { 3 | "prefix": "fstless", 4 | "body": [ 5 | "class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} extends StatelessWidget {", 6 | "const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}({ Key? key }) : super(key: key);", 7 | "", 8 | " @override", 9 | " Widget build(BuildContext context){", 10 | " return ${2:Container}(${0});", 11 | " }", 12 | "}" 13 | ], 14 | "description": "StatelessWidget snippet" 15 | }, 16 | "Stateful widget snippet": { 17 | "prefix": "fstful", 18 | "description": "Insert a StatefulWidget", 19 | "body": [ 20 | "class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} extends StatefulWidget {", 21 | " const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}({ Key? key }) : super(key: key);", 22 | "", 23 | " @override", 24 | " State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}> createState() => ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State();", 25 | "}", 26 | "", 27 | "class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State extends State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}> {", 28 | " @override", 29 | " Widget build(BuildContext context) {", 30 | " return Container(", 31 | " $2", 32 | " );", 33 | " }", 34 | "}" 35 | ] 36 | }, 37 | "Scaffold widget snippet": { 38 | "prefix": "fscaff", 39 | "body": [ 40 | "Scaffold(", 41 | " appBar: AppBar(", 42 | " title: ${1:const} Text('${2:Title}'),", 43 | " ),", 44 | " body: ${3:Container()},", 45 | ")${3:;}" 46 | ], 47 | "description": "Scaffold widget snippet" 48 | }, 49 | "EdgeInsets widget snippet with named constructor `all`": { 50 | "prefix": "fedgall", 51 | "body": ["EdgeInsets.all(${1:32.0})${0}"], 52 | "description": "EdgeInsets widget snippet with named constructor `all`" 53 | }, 54 | "Text widget snippet": { 55 | "prefix": "ftxt", 56 | "body": ["${1:const} Text('${2:text}')${0}"], 57 | "description": "Text widget snippet" 58 | }, 59 | "Dart Public Instance variable snippet": { 60 | "prefix": "dinvar", 61 | "body": ["${1:dynamic} ${2:variableName}${0}"], 62 | "description": "Instance variable snippet" 63 | }, 64 | "Dart Private instance variable snippet": { 65 | "prefix": "dprinvar", 66 | "body": ["${1:dynamic} _${2:variableName};${0}"], 67 | "description": "Dart Private instance variable snippet" 68 | }, 69 | "Flutter initState lifecycle method snippet": { 70 | "prefix": "finitlf", 71 | "body": ["@override", "void initState() {", " super.initState();", " ${0}", "}"], 72 | "description": "Flutter initState lifecycle method" 73 | }, 74 | "Dart private method snippet": { 75 | "prefix": "dprmt", 76 | "body": ["${1:void} _${2:methodName}(${3}) ${4}{", " ${0}", "}"], 77 | "description": "Dart private method snippet" 78 | }, 79 | "Dart optional named parameters constructor snippet": { 80 | "prefix": "dopnctor", 81 | "body": ["${1:constructorName}({${2}});${0}"], 82 | "description": "Dart optional named parameters constructor snippet" 83 | }, 84 | "Flutter Icon widget snippet": { 85 | "prefix": "fic", 86 | "body": ["Icon(Icons.${1:clear})${0}"], 87 | "description": "Flutter Icon widget snippet" 88 | }, 89 | "Flutter Container widget snippet": { 90 | "prefix": "fcont", 91 | "body": ["Container(", " child: ${1:Widget}(${0}),", ")"], 92 | "description": "Flutter Container widget snippet" 93 | }, 94 | "Flutter Center widget snippet": { 95 | "prefix": "fcent", 96 | "body": ["Center(", " child: ${1:Widget}(${0}),", ")"], 97 | "description": "Flutter Center widget snippet" 98 | }, 99 | "Flutter Row widget snippet": { 100 | "prefix": "frow", 101 | "body": ["Row(", " children: [${0}],", ")"], 102 | "description": "Flutter Row widget snippet" 103 | }, 104 | "Flutter Column widget snippet": { 105 | "prefix": "fcol", 106 | "body": ["Column(", " children: [${0}],", ")"], 107 | "description": "Flutter Column widget snippet" 108 | }, 109 | "SizedBox widget snippet with width and height arguments": { 110 | "prefix": "fszb", 111 | "body": ["SizedBox(width: ${1:0.0}, height: ${2:0.0})${0}"], 112 | "description": "SizedBox widget with width and height arguments" 113 | }, 114 | "SizedBox widget snippet with just width argument": { 115 | "prefix": "fszbw", 116 | "body": ["SizedBox(", " width: ${1:0.0},${0}", ")"], 117 | "description": "SizedBox widget snippet with just width argument" 118 | }, 119 | "SizedBox widget snippet with just height argument": { 120 | "prefix": "fszbh", 121 | "body": ["SizedBox(", " height: ${1:0.0},${0}", ")"], 122 | "description": "SizedBox widget snippet with just height argument" 123 | }, 124 | "Expand widget snippet": { 125 | "prefix": "fex", 126 | "body": ["Expanded(", " child: ${1:null},${0}", ")"], 127 | "description": "Expand widget snippet" 128 | }, 129 | "EdgeInsets widget snippet with named constructor `only`": { 130 | "prefix": "fedgonly", 131 | "body": ["EdgeInsets.only(${1})${0}"], 132 | "description": "EdgeInsets widget snippet with named constructor `only`" 133 | }, 134 | "EdgeInsets widget snippet with symmetric contructor `symmetric`": { 135 | "prefix": "fedgsym", 136 | "body": ["EdgeInsets.symmetric(vertical: ${1:8.0}, horizontal: ${2:8.0},)${0}"], 137 | "description": "EdgeInsets widget snippet with named constructor `symmetric`" 138 | }, 139 | "EdgeInsets widget snippet with symmetric contructor `symmetric` with only vertical parameter": { 140 | "prefix": "fedgsymv", 141 | "body": ["EdgeInsets.symmetric(vertical: ${1:8.0},)${0}"], 142 | "description": "EdgeInsets widget snippet with named constructor `symmetric` with only vertical parameter" 143 | }, 144 | "EdgeInsets widget snippet with symmetric contructor `symmetric` with only horizontal parameter": { 145 | "prefix": "fedgsymh", 146 | "body": ["EdgeInsets.symmetric(horizontal: ${1:8.0},)${0}"], 147 | "description": "EdgeInsets widget snippet with named constructor `symmetric` with only horizontal parameter" 148 | }, 149 | "Dart `List` collection snippet": { 150 | "prefix": "dlist", 151 | "body": ["List<${1:dynamic}> ${2:listName}${0}"], 152 | "description": "Dart `List` collection snippet" 153 | }, 154 | "Dart `Map` collection snippet": { 155 | "prefix": "dmap", 156 | "body": ["Map<${1:dynamic}, ${2:dynamic}> ${3:mapName}${0}"], 157 | "description": "Dart `Map` collection snippet" 158 | }, 159 | "Dart `Set` collection snippet": { 160 | "prefix": "dset", 161 | "body": ["Set<${1:dynamic}> ${2:setName}${0}"], 162 | "description": "Dart `Set` collection snippet" 163 | }, 164 | "Dart arrow function getter snippet": { 165 | "prefix": "dgetarr", 166 | "body": ["${1:dynamic} get ${2:name} => ${3:returnValue};${0}"], 167 | "description": "Dart arrow function getter snippet" 168 | }, 169 | "Dart `import as` snippet": { 170 | "prefix": "dimpas", 171 | "body": ["import '${1:packageName}' as ${2:alias}${0};"], 172 | "description": "Dart `import as` snippet" 173 | }, 174 | "Dart `import show` snippet": { 175 | "prefix": "dimpshow", 176 | "body": ["import '${1:packageName}' show ${2:member}${0};"], 177 | "description": "Dart `import show` snippet" 178 | }, 179 | "Dart `import deffered as` snippet": { 180 | "prefix": "dimplazy", 181 | "body": ["import '${1:packageName}' deferred as ${2:alias}${0};"], 182 | "description": "Dart `import deffered as` snippet" 183 | }, 184 | "Dart `import hide` snippet": { 185 | "prefix": "dimphide", 186 | "body": ["import '${1:packageName}' hide ${2:excludedMember}${0};"], 187 | "description": "Dart `import hide` snippet" 188 | }, 189 | "Dart `export hide` snippet": { 190 | "prefix": "dexhide", 191 | "body": ["export '${1:file}' hide ${2:excludedMember}${0};"], 192 | "description": "Dart `export hide` snippet" 193 | }, 194 | "Dart `export show` snippet": { 195 | "prefix": "dexshow", 196 | "body": ["export '${1:file}' show ${2:member}${0};"], 197 | "description": "Dart `export show` snippet" 198 | }, 199 | "Dart public method snippet": { 200 | "prefix": "dmt", 201 | "body": ["${1:void} ${2:methodName}(${3}) ${4}{", " ${0}", "}"], 202 | "description": "Dart public method snippet" 203 | }, 204 | "Dart `convert` lib import snippet": { 205 | "prefix": "dconvert", 206 | "body": ["import 'dart:convert'${0};"], 207 | "description": "Dart `convert` lib import snippet" 208 | }, 209 | "Dart `var` variable declaration snippet": { 210 | "prefix": "dvar", 211 | "body": ["${1:var} ${2:variableName}${0}"], 212 | "description": "Dart `var` variable declaration snippet" 213 | }, 214 | "Dart `final` variable declaration snippet": { 215 | "prefix": "dfinal", 216 | "body": ["final ${1:type} ${2:variableName} ${3:= }${0};"], 217 | "description": "Dart `final` variable declaration snippet" 218 | }, 219 | "Dart `const` variable declaration snippet": { 220 | "prefix": "dconst", 221 | "body": ["const ${1:type} ${2:variableName} ${3:= }${0};"], 222 | "description": "Dart `const` variable declaration snippet" 223 | }, 224 | "Dart public arrow function snippet": { 225 | "prefix": "darr", 226 | "body": ["${1:Object} ${2:methodName}(${3}) ${4}=> ${0};"], 227 | "description": "Dart public arrow function snippet" 228 | }, 229 | "Dart private arrow function snippet": { 230 | "prefix": "dprarr", 231 | "body": ["${1:Object} _${2:methodName}(${3}) ${4}=> ${0};"], 232 | "description": "Dart private arrow function snippet" 233 | }, 234 | "Add material's package import statement": { 235 | "prefix": "fimpmat", 236 | "body": ["import 'package:flutter/material.dart';"], 237 | "description": "Add material's package import statement" 238 | }, 239 | "Add meta package import statement": { 240 | "prefix": "dimpmeta", 241 | "body": ["import 'package:meta/meta.dart';"], 242 | "description": "Add meta package import statement" 243 | }, 244 | "Flutter StreamBuilder widget snippet": { 245 | "prefix": "fstream", 246 | "body": [ 247 | "StreamBuilder<${1:dynamic}>( ", 248 | " stream: ${2:yourStream},", 249 | " builder: (BuildContext context, AsyncSnapshot<${1:dynamic}> snapshot) {", 250 | " if (snapshot.hasData) {", 251 | " // TODO: do something with the data", 252 | " return ${3:Container()};", 253 | " } else if (snapshot.hasError) {", 254 | " // TODO: do something with the error", 255 | " return ${4:Text(snapshot.error.toString())};", 256 | " }", 257 | " // TODO: the data is not ready, show a loading indicator", 258 | " return ${5:Center(child: CircularProgressIndicator())};", 259 | " },", 260 | ")" 261 | ], 262 | "description": "Flutter StreamBuilder widget snippet" 263 | }, 264 | "Flutter ElevatedButton snippet": { 265 | "prefix": "felbtn", 266 | "body": [ 267 | "ElevatedButton(", 268 | " child: const Text('${1:Button label}'),", 269 | " onPressed: () {},", 270 | ")${0}" 271 | ], 272 | "description": "Flutter ElevatedButton snippet" 273 | }, 274 | "Flutter bloc provider snippet": { 275 | "prefix": "fblocprov", 276 | "body": [ 277 | "class ${1:Bloc}Provider extends InheritedWidget {", 278 | " final ${2:BlocTypeName} bloc = ${2:BlocTypeName}();", 279 | "", 280 | " ${1:Bloc}Provider({Key key, Widget child})", 281 | " : super(key: key, child: child);", 282 | "", 283 | " @override", 284 | " bool updateShouldNotify(InheritedWidget oldWidget) => true;", 285 | "", 286 | " static ${2:BlocTypeName} of(BuildContext context) {", 287 | " return (context.inheritFromWidgetOfExactType(${1:Bloc}Provider)", 288 | " as ${1:Bloc}Provider)", 289 | " .bloc;", 290 | " }", 291 | "}" 292 | ], 293 | "description": "Flutter bloc provider snippet" 294 | }, 295 | "Dart anonymous function": { 296 | "prefix": "dan", 297 | "body": ["(${1}) ${2}{${0}}"], 298 | "description": "Dart anonymous function" 299 | }, 300 | "Dart Class snippet": { 301 | "prefix": "dcla", 302 | "body": ["class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} {", "${0}", "}"], 303 | "description": "Dart Class snippet" 304 | }, 305 | "Dart Class snippet with extends keyword": { 306 | "prefix": "dclae", 307 | "body": [ 308 | "class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} extends ${2} {", 309 | " ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}(${0}) : super();", 310 | "}" 311 | ], 312 | "description": "Dart Class snippet with extends keyword" 313 | } 314 | } 315 | --------------------------------------------------------------------------------