Skip to content

yeasin50/Creating_Live_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create LiveTemplate


Local LiveTemplate

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

Setting Icon

then

Live template loc

Let's create our group from left corner and give a name

click on our group and then + sing again now choose live template

im creating snackBar here,

  • Abbreviation short form of this code that brings the Template text

  • Description details of the template

  • $END$ is a reserved keyword where our cursor will end. another one is Statement & 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

our ssbar is complete, save by clicking OK

ssbar

we can find it here

simply type ssbar, it will show our custom live template

press enter/tab

if we have more variables press tab to move next variable.

Sharing this ssbar Live-template to the Flutter-intelliJ community

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 {&#10;  @override&#10;  Widget build(BuildContext context) {&#10;    return Container($END$);&#10;  }&#10;}&#10;" description="New Stateless widget" toReformat="false" toShortenFQNames="true">
<variable name="NAME" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART_TOPLEVEL" value="true" />
</context>
</template>

Let's add our ssbar inside Flutter group

<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 .


Getting Started

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.

About

creating live template for flutter

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published