Use VSCode's code templates to improve coding efficiency

foreword

In the last article, we MobXgave an overall introduction to the state management plugin. After using MobXit , the code generator can save us a lot of coding workload. In line with the principle of not doing anything that can be done by a computer, this article introduces how to let a computer create code that MobXcannot be generated. This is thanks to the custom template code User Snippetsfeature provided by VSCode.

Template code for VSCode

VSCode itself integrates a lot of code templates and template extensions, such as forloop , and then we usually use StatelessWidgetand StatefulWidget. In effect, the template code is a configuration jsonstring .

Let's take a look at StatefulWidgetthe template code for (requires the Awesome Flutter Snippetsextension to be installed). When we type statefulWand press Enter to confirm, the corresponding code fragment will be automatically inserted, and then the cursor will be positioned at the class name. When the class name is changed, all related will namebe replaced.
image.png
Let's take a look at what the json corresponding to this template code looks like.

"Stateful Widget"

Guess you like

Origin blog.csdn.net/shuijian00/article/details/123215115