支持“ Dart”摘要

时间:2019-02-21 16:21:20

标签: dart flutter code-snippets

我想在VS Code中支持Dart代码段。我也想使用Snippet Creator(https://github.com/nikitaKunevich/vscode-snippet-creator)之类的工具来执行此操作,但这似乎不起作用,因为'dart'不是一种语言选择。是否可以添加“ dart”作为选项,以便我可以使用代码片段创建器在“ * .dart”文件中包含代码片段?

1 个答案:

答案 0 :(得分:0)

control + shift + p>摘要> dart.json添加此代码

{
    "stateless": {
      "prefix": "fless",
      "body": [
        "import 'package:flutter/material.dart';",
        "class $1 extends StatelessWidget {",
        "\t@override",
        "\tWidget build(BuildContext context) {",
        "\t\treturn Container(",
        "\t\t\t$2",
        "\t\t);",
        "\t}",
        "}"
      ]
    },

    "stateful": {
      "prefix": "ffull",
      "body": [
        "import 'package:flutter/material.dart';",
        "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}",
        "} "
      ]
    }

} // control + shift + p>摘要> dart.json添加此代码