Skip to content

Commit 96f0c4e

Browse files
committed
[Breaking Changes] - A overhaul to bring us in line with the VS plugin and make shortcuts consistent
1 parent bb229c2 commit 96f0c4e

File tree

3 files changed

+86
-35
lines changed

3 files changed

+86
-35
lines changed

README.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,45 @@
66

77
An Intellij & Android Studio plugin that adds Live Templates to your IDE saving time writing the boilerplate in Flutter.
88

9-
109
## Available Snippets
11-
| Shortcut| Flutter Docs| Description|
12-
| ---------- | ------------------------ | -------------- |
13-
|`alertDialog`|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|Creates a showDialog that returns with AlertDialog|
14-
|`animBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/AnimationBuilder-class.html)|Creates an AnimationBuilder|
15-
|`aspectRatio`|[View Docs](https://api.flutter.dev/flutter/widgets/AspectRatio-class.html)|Creates an AspectRatio|
16-
|`column`|[View Docs](https://docs.flutter.io/flutter/widgets/Column-class.html)|Creates a Column Widget|
17-
|`container`|[View Docs](https://docs.flutter.io/flutter/widgets/Container-class.html)|Creates a Container Widget|
18-
|`customClipper`|[View Docs](https://api.flutter.dev/flutter/rendering/CustomClipper-class.html)|Creates a CustomClipper|
19-
|`customPainter`|[View Docs](https://api.flutter.dev/flutter/rendering/CustomPainter-class.html)|Creates a CustomPainter|
20-
|`customScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html)|Creates a CustomScrollView|
21-
|`futureBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html)|Creates a FutureBuilder|
22-
|`importMat`|[View Docs](https://api.flutter.dev/flutter/material/material-library.html)|Adds Material Import|
23-
|`importCup`|[View Docs](https://api.flutter.dev/flutter/cupertino/cupertino-library.html)|Adds Cupertino Import|
24-
|`layoutBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html)|Creates a LayoutBuilder|
25-
|`listViewBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/ListView.builder.html)|Creates a ListView.builder()|
26-
|`orienatatBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/OrientationBuilder-class.html)|Creates a OrientationBuilder|
27-
|`row`|[View Docs](https://docs.flutter.io/flutter/widgets/Row-class.html)|Creates a Row Widget|
28-
|`scfAll`|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|
29-
|`scfAppBar`| |Creates a Scaffold containing an Appbar|
30-
|`scfAppBarFab`| |Creates a Scaffold containing an Appbar and Floating Action Button|
31-
|`scfAppBarBtmNav`| |Creates a Scaffold containing an Appbar and Bottom Navigation Bar|
32-
|`singleChildScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html)|Creates a SingleChildScrollView|
33-
|`streamBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/StreamBuilder-class.html)|Creates a StreamBuilder|
34-
|`stfulBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/StatefulBuilder/StatefulBuilder.html)|Creates a StatefulBuilder|
35-
|`text`|[View Docs](https://docs.flutter.io/flutter/widgets/Text-class.html)|Creates a Text Widget|
10+
### Generic
11+
| Shortcut|Expanded|Description|Flutter Docs|
12+
| ---------- | ----------| -------------- | -------------- |
13+
|`alertDialog`| |Creates a showDialog that returns with AlertDialog|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|
14+
|`animatedBldr`|Animated Builder|Creates an Animated Builder. The child widget is passed to the builder|[View Docs](https://docs.flutter.io/flutter/widgets/AnimationBuilder-class.html)|
15+
|`aspectRatio`| |Creates an AspectRatio|[View Docs](https://api.flutter.dev/flutter/widgets/AspectRatio-class.html)|
16+
|`column`| |Creates a Column Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Column-class.html)|
17+
|`container`| |Creates a Container Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Container-class.html)|
18+
|`customClipper`|Custom Clipper|Used for creating custom shapes|[View Docs](https://api.flutter.dev/flutter/rendering/CustomClipper-class.html)|
19+
|`customPainter`|Custom Painter|Used for creating custom paint|[View Docs](https://api.flutter.dev/flutter/rendering/CustomPainter-class.html)|
20+
|`customScrollV`| Custom ScrollView|Creates a ScrollView that creates custom scroll effects using slivers. If the primary argument is true, the controller must be null.|[View Docs](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html)|
21+
|`dis`|Dispose|Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again.|[View Docs](https://api.flutter.dev/flutter/widgets/State/dispose.html)|
22+
|`futureBldr`|Future Builder|Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future|[View Docs](https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html)|
23+
|`initS`|InitState|Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates.|[View Docs](https://api.flutter.dev/flutter/widgets/State/initState.html)|
24+
|`layoutBldr`|Layout Builder|Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints.|[View Docs](https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html)|
25+
|`listViewBldr`|ListView.Builder|Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null itemCount improves the ability of the ListView to estimate the maximum scroll extent.|[View Docs](https://docs.flutter.io/flutter/widgets/ListView.builder.html)|
26+
|`orientationBldr`|Orientation Builder|Creates a builder which allows for the orientation of the device to be specified and referenced|[View Docs](https://api.flutter.dev/flutter/widgets/OrientationBuilder-class.html)|
27+
|`row`| |Creates a Row Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Row-class.html)|
28+
|`singleChildSV`|Single Child Scroll View|Creates a scroll view with a single child|[View Docs](https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html)|
29+
|`streamBldr`| Stream Builder |Creates a new StreamBuilder that builds itself based on the latest snapshot of interaction with the specified stream |[View Docs](https://docs.flutter.io/flutter/widgets/StreamBuilder-class.html)|
30+
|`statefulBldr`|Stateful Builder|Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree.|[View Docs](https://api.flutter.dev/flutter/widgets/StatefulBuilder/StatefulBuilder.html)|
31+
|`text`| |Creates a Text Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Text-class.html)|
32+
33+
### Cupertino Specific
34+
| Shortcut| Exapnded | Description| Flutter Docs |
35+
| ---------- | ------------------------ | -------|------------- |
36+
|`cupeApp`|Cupertino App |Create a New Cupertino App| [View Docs](https://api.flutter.dev/flutter/cupertino/CupertinoApp-class.html)|
37+
|`importC`| Cupertino Package|Import Cupertino package.| [View Docs](https://api.flutter.dev/flutter/cupertino/cupertino-library.html)|
38+
### Material Specific
39+
| Shortcut| Expanded | Description| Flutter Docs |
40+
| ---------- | ------------------------ | -------|------------- |
41+
|`importM`| Material Package |Import Material package|[View Docs](https://api.flutter.dev/flutter/material/material-library.html)|
42+
|`mateApp`| Material App |Create a new Material App|[View Docs](https://api.flutter.dev/flutter/material/MaterialApp-class.html) |
43+
|`scfAll`| Scaffold |Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|
44+
|`scfAppBar`| Scaffold |Creates a Scaffold containing an Appbar| |
45+
|`scfAppBarFab`| Scaffold |Creates a Scaffold containing an Appbar and Floating Action Button| |
46+
|`scfAppBarBtmNav`| Scaffold |Creates a Scaffold containing an Appbar and Bottom Navigation Bar||
47+
3648

3749
## Plugin Supports the Following IDEs:
3850
* Android Studio

resources/META-INF/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<idea-plugin>
33
<id>com.herbert.george.flutter-snippets</id>
44
<name>Flutter Snippets</name>
5-
<version>0.1.9</version>
5+
<version>1.0.0-beta</version>
66
<vendor>George Herbert</vendor>
77
<description><![CDATA[
88
<p>Provides live templates for Flutter to save time writing boilerplate.</p>
@@ -105,7 +105,7 @@ The following commands are supported:
105105
<td>Creates a Text Widget</td>
106106
</tr>
107107
</table>]]></description>
108-
<change-notes>Fix trailing commas on some widgets to help dartfmt</change-notes>
108+
<change-notes>[Breaking Changes] - A overhaul to bring us in line with the VS plugin and make short cuts consistent ADD NEW WIDEGETS TO ABOVE TABLE</change-notes>
109109
<idea-version since-build="141.0" />
110110
<depends>com.intellij.modules.java</depends>
111111
<extensions defaultExtensionNs="com.intellij">

resources/liveTemplates/Flutter.xml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templateSet group="Flutter">
33
<!-- AnimatedBuilder -->
4-
<template name="animBldr" value="AnimatedBuilder(&#10; animation: $animationController$,&#10; child: $childWidget$,&#10; builder: (BuildContext context, Widget child) {&#10; return $buildWidget$;&#10; },&#10;);" description="New AnimatedBuilder" toReformat="false" toShortenFQNames="true">
4+
<template name="animatedBldr" value="AnimatedBuilder(&#10; animation: $animationController$,&#10; child: $childWidget$,&#10; builder: (BuildContext context, Widget child) {&#10; return $buildWidget$;&#10; },&#10;);" description="New AnimatedBuilder" toReformat="false" toShortenFQNames="true">
55
<variable name="animationController" expression="&quot;animationController&quot;" defaultValue="" alwaysStopAt="true" />
66
<variable name="childWidget" expression="&quot;childWidget&quot;" defaultValue="" alwaysStopAt="true" />
77
<variable name="buildWidget" expression="&quot;buildWidget&quot;" defaultValue="" alwaysStopAt="true" />
@@ -37,7 +37,7 @@
3737
</context>
3838
</template>
3939
<!-- SingleChildScrollView-->
40-
<template name="singleChildScrollV" value="SingleChildScrollView(&#10;controller: $controller$, // Optional&#10;child: $widget$,&#10;)," description="New SingleChildScrollView" toReformat="false" toShortenFQNames="true">
40+
<template name="singleChildSV" value="SingleChildScrollView(&#10;controller: $controller$, // Optional&#10;child: $widget$,&#10;)," description="New SingleChildScrollView" toReformat="false" toShortenFQNames="true">
4141
<variable name="controller" expression="&quot;controller&quot;" defaultValue="" alwaysStopAt="true" />
4242
<variable name="widget" expression="&quot;widget&quot;" defaultValue="" alwaysStopAt="true" />
4343
<context>
@@ -60,7 +60,7 @@
6060
<template name="listviewBldr"
6161
value="ListView.builder(itemCount: $COUNT$,itemBuilder: (BuildContext context, int index) {return $WIDGET$;}, ),"
6262
description="Create ListView.builder" toReformat="true" toShortenFQNames="true">
63-
<variable name="COUNT" expression="&quot;future&quot;" defaultValue="" alwaysStopAt="true"/>
63+
<variable name="COUNT" expression="&quot;count&quot;" defaultValue="" alwaysStopAt="true"/>
6464
<variable name="WIDGET" expression="&quot;widget&quot;" defaultValue="" alwaysStopAt="true"/>
6565
<context>
6666
<option name="DART_STATEMENT" value="true"/>
@@ -113,26 +113,26 @@
113113
</context>
114114
</template>
115115
<!-- StatefulBuilder-->
116-
<template name="stfulBldr" value="StatefulBuilder(&#10;builder: (BuildContext context, StateSetter setState){&#10;return $widget$&#10;}&#10;)," description="New Stateful Builder" toReformat="false" toShortenFQNames="true">
116+
<template name="statefulBldr" value="StatefulBuilder(&#10;builder: (BuildContext context, StateSetter setState){&#10;return $widget$&#10;}&#10;)," description="New Stateful Builder" toReformat="false" toShortenFQNames="true">
117117
<variable name="widget" expression="&quot;widget&quot;" defaultValue="" alwaysStopAt="true" />
118118
<context>
119119
<option name="DART_STATEMENT" value="true" />
120120
</context>
121121
</template>
122122
<!-- OrientationBuilder-->
123-
<template name="orientatBldr" value="OrientationBuilder(&#10; builder: (BuildContext context, Orientation orientation) {&#10;return GridView.count(&#10;// Create a grid with 2 columns in portrait mode, or 3 columns in&#10;// landscape mode.&#10;crossAxisCount: orientation == Orientation.portrait ? 2 : 3,&#10;);&#10;},&#10;);" description="New OrientationBuilder" toReformat="false" toShortenFQNames="true">
123+
<template name="orientationBldr" value="OrientationBuilder(&#10; builder: (BuildContext context, Orientation orientation) {&#10;return GridView.count(&#10;// Create a grid with 2 columns in portrait mode, or 3 columns in&#10;// landscape mode.&#10;crossAxisCount: orientation == Orientation.portrait ? 2 : 3,&#10;);&#10;},&#10;);" description="New OrientationBuilder" toReformat="false" toShortenFQNames="true">
124124
<context>
125125
<option name="DART_STATEMENT" value="true" />
126126
</context>
127127
</template>
128128
<!-- Material Package Import-->
129-
<template name="importMat" value="import 'package:flutter/material.dart';" description="Import Material Package" toReformat="false" toShortenFQNames="true">
129+
<template name="importM" value="import 'package:flutter/material.dart';" description="Import Material Package" toReformat="false" toShortenFQNames="true">
130130
<context>
131131
<option name="DART_TOPLEVEL" value="true" />
132132
</context>
133133
</template>
134134
<!-- Cupertino Package Import-->
135-
<template name="importCup" value="import 'package:flutter/cupertino.dart';" description="Import Cupertino Package" toReformat="false" toShortenFQNames="true">
135+
<template name="importC" value="import 'package:flutter/cupertino.dart';" description="Import Cupertino Package" toReformat="false" toShortenFQNames="true">
136136
<context>
137137
<option name="DART_TOPLEVEL" value="true" />
138138
</context>
@@ -196,4 +196,43 @@
196196
<option name="DART_STATEMENT" value="true" />
197197
</context>
198198
</template>
199+
200+
<!-- Cupertino App-->
201+
202+
<template name="cupeApp" value="import 'package:flutter/cupertino.dart';&#10; &#10;void main() =&gt; runApp($className$());&#10; &#10;class $className$ extends StatelessWidget {&#10; @override&#10; Widget build(BuildContext context) {&#10; return CupertinoApp(&#10; title: 'Cupertino App',&#10; home: CupertinoPageScaffold(&#10; navigationBar: CupertinoNavigationBar(&#10; middle: Text('Cupertino App Bar'),&#10; ),&#10; child: Center(&#10; child: Container(&#10; child: Text('Hello World'),&#10; ),&#10; ),&#10; ),&#10; );&#10; }&#10;}" description="Create a New Cupertino App" toReformat="false" toShortenFQNames="true">
203+
<variable name="className" expression="&quot;MyApp&quot;" defaultValue="" alwaysStopAt="true" />
204+
<context>
205+
<option name="DART_TOPLEVEL" value="true" />
206+
</context>
207+
</template>
208+
209+
<!-- Material App-->
210+
211+
<template name="mateApp" value="import 'package:flutter/material.dart';&#10; &#10;void main() =&gt; runApp($className$());&#10; &#10;class $className$ extends StatelessWidget {&#10; @override&#10; Widget build(BuildContext context) {&#10; return MaterialApp(&#10; title: 'Material App',&#10; home: Scaffold(&#10; appBar: AppBar(&#10; title: Text('Material App Bar'),&#10; ),&#10; body: Center(&#10; child: Container(&#10; child: Text('Hello World'),&#10; ),&#10; ),&#10; ),&#10; );&#10; }&#10;}" description="Create a New Material App" toReformat="false" toShortenFQNames="true">
212+
<variable name="className" expression="&quot;MyApp&quot;" defaultValue="" alwaysStopAt="true" />
213+
<context>
214+
<option name="DART_TOPLEVEL" value="true" />
215+
</context>
216+
</template>
217+
218+
<!-- initState-->
219+
220+
<template name="initS" value="@override&#10;void initState() { &#10; super.initState();&#10; // Add code after super&#10;}" description="Add initState Override" toReformat="false" toShortenFQNames="true">
221+
<context>
222+
<option name="DART_STATEMENT" value="true" />
223+
</context>
224+
</template>
225+
226+
<!-- Dispose-->
227+
228+
<template name="dis" value="@override&#10;void dispose() { &#10; // Add code before the super&#10; super.dispose();&#10;}" description="Add dispose Override" toReformat="false" toShortenFQNames="true">
229+
<context>
230+
<option name="DART_STATEMENT" value="true" />
231+
</context>
232+
</template>
233+
234+
235+
236+
237+
199238
</templateSet>

0 commit comments

Comments
 (0)