Skip to content

Instantly share code, notes, and snippets.

@bkanhu
Last active March 18, 2021 09:28
Show Gist options
  • Save bkanhu/b624a3741ec73924e6416da37f57ded4 to your computer and use it in GitHub Desktop.
Save bkanhu/b624a3741ec73924e6416da37f57ded4 to your computer and use it in GitHub Desktop.
Flutter snippets for making stateful and stateless widgets. Open Visual Studio Code press "Control+Shift+P", Search for Snippet, then choose dart. and paste this code to that "dart.json" file and save it.
{
"stateless": {
"prefix": "stless",
"body": [
"class $1 extends StatelessWidget {",
"\t@override",
"\tWidget build(BuildContext context) {",
"\t\treturn Container(",
"\t\t\t$2",
"\t\t);",
"\t}",
"}"
]
},
"stateful": {
"prefix": "stfull",
"body": [
"class $1 extends StatefulWidget {",
"\t@override",
" \t_$1State createState() => _$1State();",
"}",
"class _$1State extends State<$1> {",
" \t@override",
" \tWidget build(BuildContext context) {",
"\t\treturn Container(",
" \t\t\t$2",
"\t\t);",
"\t}",
"} "
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment