Flutter Vscode 快捷代码片段

{

"StatelessWidget": {

"prefix": "sl",

"body": [

"class ${1:WidgetName} extends StatelessWidget {",

"\t@override",

"\tWidget build(BuildContext context) {",

"\t\treturn ${2:Container}();",

"\t}",

"}"

],

"description": "StatelessWidget"

},

"StatefulWidget": {

"prefix": "sf",

"body": [

"class ${1:WidgetName} extends StatefulWidget {",

"\t@override",

"\t_${1:WidgetName}State createState() => _${1:WidgetName}State();",

"}\n",

"class _${1:WidgetName}State extends State<${1:WidgetName}> {",

"\t@override",

"\tWidget build(BuildContext context) {",

"\t\treturn ${2:Container}();",

"\t}",

"}"

],

"description": "StatefulWidget"

},

"StatelessWidget with Scaffold": {

"prefix": "sls",

"body": [

"class ${1:WidgetName} extends StatelessWidget {",

"\t@override",

"\tWidget build(BuildContext context) {",

"\t\treturn ${Scaffold}(",

"\t\t\tappBar: AppBar(",

"\t\t\t\ttitle: Text('${1:WidgetName}'),",

"\t\t\t\televation: 0.0,",

"\t\t\t),${2}",

"\t\t);",

"\t}",

"}"

],

"description": "StatelessWidget with Scaffold"

},

"StatefulWidget with Scaffold": {

"prefix": "sfs",

"body": [

"class ${1:WidgetName} extends StatefulWidget {",

"\t@override",

"\t_${1:WidgetName}State createState() => _${1:WidgetName}State();",

"}\n",

"class _${1:WidgetName}State extends State<${1:WidgetName}> {",

"\t@override",

"\tWidget build(BuildContext context) {",

"\t\treturn ${Scaffold}(",

"\t\t\tappBar: AppBar(",

"\t\t\t\ttitle: Text('${1:WidgetName}'),",

"\t\t\t\televation: 0.0,",

"\t\t\t),${2}",

"\t\t);",

"\t}",

"}"

],

"description": "StatefulWidget with Scaffold"

},

"InheritedWidget": {

"prefix": "ih",

"body": [

"class ${1:WidgetName} extends InheritedWidget {",

"\tfinal Widget child;",

"\t${2}",

"\t${1:WidgetName}({",

"\t\tthis.child,",

"\t\t${2}",

"\t}) : super(child: child);\n",

"\tstatic ${1:WidgetName} of(BuildContext context) =>",

"\t\t\tcontext.inheritFromWidgetOfExactType(${1:WidgetName});\n",

"\t@override",

"\tbool updateShouldNotify(${1:WidgetName} oldWidget) {",

"\t\treturn true;",

"\t}",

"}"

],

"description": "InheritedWidget"

},

"setState": {

"prefix": "ss",

"body": [

"setState(() {${1}});",

],

"description": "setState"

},

"build": {

"prefix": "build",

"body": [

"@override",

"Widget build(BuildContext context) {",

"\treturn ${1:Container}(${2});",

"}",

],

"description": "Build Method"

},

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值