Live-template is a time saving development process. I'm going to show you how you can create your won custom live templates.
if you are on android-studio or IntelliJ , follow along
goto top left corner
File > settings > Editors > Live Templates
then
im creating snackBar here,
-
Abbreviation
short form of this code that brings theTemplate text
-
Description
details of the template -
$END$
is a reserved keyword where our cursor will end. another one isStatement
& used for wrap with snippets. -
bottom
Statement
we define the places. -
Shorten FQ names
used for shorting libraries name(this example doesn't count), check on Timer template -
a variable name must be start & end with
$
like$variable$
, -
Edit variables
control variable names
simply type ssbar
, it will show our custom live template
press enter/tab
if we have more variables press tab
to move next variable.
check CustomTemplate.md
Navigate to flutter-intellij/resources/liveTemplates/[flutter_miscellaneous.xml
file.
We can see their live templates. The group named there is Flutter
, Template named stless
<template name="stless" value="class $NAME$ extends StatelessWidget { @override Widget build(BuildContext context) { return Container($END$); } } " description="New Stateless widget" toReformat="false" toShortenFQNames="true">
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART_TOPLEVEL" value="true" />
</context>
</template>
<variable name="message" expression="" defaultValue="message" alwaysStopAt="true" />
<context>
<option name="DART_STATEMENT" value="true" />
</context>
</template>
We are using toReformat="true"
, we don't have to give spaces and line numbers like restless .
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.