foreword
In the last article, we MobX
gave an overall introduction to the state management plugin. After using MobX
it , 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 MobX
cannot be generated. This is thanks to the custom template code User Snippets
feature provided by VSCode.
Template code for VSCode
VSCode itself integrates a lot of code templates and template extensions, such as for
loop , and then we usually use StatelessWidget
and StatefulWidget
. In effect, the template code is a configuration json
string .
Let's take a look at StatefulWidget
the template code for (requires the Awesome Flutter Snippets
extension to be installed). When we type statefulW
and 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 name
be replaced.
Let's take a look at what the json corresponding to this template code looks like.
"Stateful Widget"