Skip to content

Commit c52e29c

Browse files
authored
0.1.3 (#1)
Add customScrollV (CustomScrollView) Add layoutBldr (LayoutBuilder) Add singleChildScrollV (SingleChildScrollView) Add sections to plugin.xml for readability
1 parent 0562830 commit c52e29c

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/flutter-snippets.zip
33
/.idea/
44
/out/
5-
*.dart
5+
/*.dart

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ An Intellij & Android Studio plugin that adds Live Templates to your IDE saving
77
| ---------- | ------------------------ | -------------- |
88
|`alertDialog`|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|Creates a showDialog that returns with AlertDialog|
99
|`animBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/AnimationBuilder-class.html)|Creates an AnimationBuilder|
10+
|`customScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html)|Creates a CustomScrollView|
1011
|`futureBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html)|Creates a FutureBuilder|
12+
|`layoutBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html)|Creates a LayoutBuilder|
1113
|`listViewBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/ListView.builder.html)|Creates a ListView.builder()|
1214
|`scfAll`|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|
1315
|`scfAppBar`| |Creates a Scaffold containing an Appbar|
1416
|`scfAppBarFab`| |Creates a Scaffold containing an Appbar and Floating Action Button|
1517
|`scfAppBarBtmNav`| |Creates a Scaffold containing an Appbar and Bottom Navigation Bar|
18+
|`singleChildScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html)|Creates a SingleChildScrollView|
1619
|`streamBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/StreamBuilder-class.html)|Creates a StreamBuilder|
1720

1821
## Plugin Supports the Following IDEs:

resources/META-INF/plugin.xml

Lines changed: 14 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.2</version>
5+
<version>0.1.3</version>
66
<vendor>George Herbert</vendor>
77
<description><![CDATA[
88
<p>Provides live templates for Flutter to save time writing boilerplate.</p>
@@ -19,10 +19,18 @@ The following commands are supported:
1919
<tr>
2020
<td>animBldr</td>
2121
<td>Creates an AnimationBuilder</td>
22+
</tr>
23+
<tr>
24+
<td>customScrollV</td>
25+
<td>Creates a CustomScrollView</td>
2226
</tr>
2327
<tr>
2428
<td>futureBldr</td>
2529
<td>Creates a FutureBuilder</td>
30+
</tr>
31+
<tr>
32+
<td>layoutBldr</td>
33+
<td>Creates a LayoutBuilder</td>
2634
</tr>
2735
<tr>
2836
<td>listViewBldr</td>
@@ -43,13 +51,17 @@ The following commands are supported:
4351
<tr>
4452
<td>scfAppBarBtmNav</td>
4553
<td>Creates a Scaffold containing an Appbar and Bottom Navigation Bar</td>
54+
</tr>
55+
<tr>
56+
<td>singleChildScrollV</td>
57+
<td>Creates a SingleChildScrollView</td>
4658
</tr>
4759
<tr>
4860
<td>streamBldr</td>
4961
<td>Creates a StreamBuilder</td>
5062
</tr>
5163
</table>]]></description>
52-
<change-notes>Add support for animBldr (Animation Builder) and a few various Scaffold options (scfAppBar, scfAppBarFab and scfAppBarBtmNav)</change-notes>
64+
<change-notes>Add support for customScrollV (CustomScrollView), layoutBldr (LayoutBuilder) and singleChildScrollV (SingleChildScrollView)</change-notes>
5365
<idea-version since-build="141.0" />
5466
<depends>com.intellij.modules.java</depends>
5567
<extensions defaultExtensionNs="com.intellij">

resources/liveTemplates/Flutter.xml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templateSet group="Flutter">
3-
3+
<!-- AnimatedBuilder -->
44
<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">
55
<variable name="animationController" expression="&quot;animationController&quot;" defaultValue="" alwaysStopAt="true" />
66
<variable name="childWidget" expression="&quot;childWidget&quot;" defaultValue="" alwaysStopAt="true" />
@@ -9,7 +9,16 @@
99
<option name="DART_STATEMENT" value="true" />
1010
</context>
1111
</template>
12-
12+
<!-- CustomScrollView-->
13+
<template name="customScrollV" value="CustomScrollView(&#10;slivers: &lt;Widget&gt;[&#10;$childWidget1$,&#10;$childWidget2$,&#10;$childWidget3$,&#10;],&#10;)" description="New CustomScrollView" toReformat="false" toShortenFQNames="true">
14+
<variable name="childWidget1" expression="&quot;childWidget1&quot;" defaultValue="" alwaysStopAt="true" />
15+
<variable name="childWidget2" expression="&quot;childWidget2&quot;" defaultValue="" alwaysStopAt="true" />
16+
<variable name="childWidget3" expression="&quot;childWidget3&quot;" defaultValue="" alwaysStopAt="true" />
17+
<context>
18+
<option name="DART_STATEMENT" value="true" />
19+
</context>
20+
</template>
21+
<!-- FutureBuilder-->
1322
<template name="futureBldr"
1423
value="FutureBuilder(&#10;future: $FUTURE$,initialData: $INITIAL$,builder: (BuildContext context, AsyncSnapshot snapshot) {if (snapshot.hasData) {if (snapshot.data!=null) {return $WIDGET$;} else {return CircularProgressIndicator();}}),"
1524
description="Create FutureBuilder" toReformat="true" toShortenFQNames="true">
@@ -20,7 +29,22 @@
2029
<option name="DART_STATEMENT" value="true"/>
2130
</context>
2231
</template>
23-
32+
<!-- LayoutBuilder-->
33+
<template name="layoutBldr" value="LayoutBuilder(&#10;builder: (BuildContext context, BoxConstraints constraints) {&#10;return $widget$;&#10;},&#10;)," description="New LayoutBuilder" toReformat="false" toShortenFQNames="true">
34+
<variable name="widget" expression="&quot;widget&quot;" defaultValue="" alwaysStopAt="true" />
35+
<context>
36+
<option name="DART_STATEMENT" value="true" />
37+
</context>
38+
</template>
39+
<!-- SingleChildScrollView-->
40+
<template name="singleChildScrollV" value="SingleChildScrollView(&#10;controller: $controller$, // Optional&#10;child: $widget$,&#10;)," description="New SingleChildScrollView" toReformat="false" toShortenFQNames="true">
41+
<variable name="controller" expression="&quot;controller&quot;" defaultValue="" alwaysStopAt="true" />
42+
<variable name="widget" expression="&quot;widget&quot;" defaultValue="" alwaysStopAt="true" />
43+
<context>
44+
<option name="DART_STATEMENT" value="true" />
45+
</context>
46+
</template>
47+
<!-- StreamBuilder-->
2448
<template name="streamBldr"
2549
value="StreamBuilder(stream: $STREAM$, builder: (BuildContext context, AsyncSnapshot snapshot) {if(snapshot.hasError) return $ERRORWIDGET$; switch (snapshot.connectionState) {case ConnectionState.none: return $DEFAULTWIDGET$;case ConnectionState.waiting: return $LOADINGWIDGET$;case ConnectionState.active: return $ACTIVEWIDGET$;case ConnectionState.done: return $FINISHEDWIDGET$;}return null; // unreachable}, ),"
2650
description="Create StreamBuilder" toReformat="true" toShortenFQNames="true">
@@ -42,7 +66,7 @@
4266
<option name="DART_STATEMENT" value="true"/>
4367
</context>
4468
</template>
45-
69+
<!-- showDialog-->
4670
<template name="showDialog"
4771
value="showDialog&lt;void&gt;(&#10;context: $context$,&#10;barrierDismissible: $dismiss$, // false = user must tap button, true = tap outside dialog&#10;builder: (BuildContext dialogContext){&#10;return AlertDialog(&#10;title: Text('$title$'),&#10;content: Text('$content$'),&#10;actions: &lt;Widget&gt;[&#10;FlatButton(&#10;child: Text('$buttonText$'),&#10;onPressed: () {&#10;Navigator.of(dialogContext).pop(); // Dismiss alert dialog&#10;},&#10;),&#10;],&#10;);&#10;},&#10;);"
4872
description="New AlertDialog" toReformat="false" toShortenFQNames="true">
@@ -55,7 +79,7 @@
5579
<option name="DART_STATEMENT" value="true"/>
5680
</context>
5781
</template>
58-
82+
<!-- New Scaffold with AppBar, Fab and Bottom Nav Bar-->
5983
<template name="scfAll" value="int _index = 0; // Make sure this is outside build(), otherwise every setState will chage the value back to 0 &#10;&#10;return Scaffold(&#10;appBar: AppBar(&#10;title: Text('$appbarTitle$'),&#10;),&#10;body: Center(&#10;child: Container(child: Text('You are looking at the message for bottom navigation item $_index')),&#10;),&#10;bottomNavigationBar: BottomNavigationBar(&#10;onTap: (tappedItemIndex)=&gt; setState(() {&#10;_index = tappedItemIndex;&#10;}),&#10;currentIndex: _index,&#10;items: [&#10;BottomNavigationBarItem(icon: Icon(Icons.av_timer), title: Text('$navBarItem1Text$')),&#10;BottomNavigationBarItem(icon: Icon(Icons.add), title: Text('$navBarItem2Text$'))&#10;]),&#10;floatingActionButton: FloatingActionButton(&#10;onPressed: () =&gt; setState(() {&#10;=_index = 0;&#10;}),&#10;tooltip: 'Reset Navigation Index',&#10; child: Icon(Icons.clear), //Change Icon&#10;),&#10;floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, //Change for different locations&#10;);" description="New Scaffold with AppBar, Fab and Bottom Nav Bar" toReformat="false" toShortenFQNames="true">
6084
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
6185
<variable name="navBarItem1Text" expression="&quot;navBarItem1Text&quot;" defaultValue="" alwaysStopAt="true" />
@@ -64,22 +88,22 @@
6488
<option name="DART_STATEMENT" value="true" />
6589
</context>
6690
</template>
67-
91+
<!-- New Scaffold with AppBar-->
6892
<template name="scfAppBar" value="return Scaffold(&#10;appBar: AppBar(&#10;title: Text('$appbarTitle$'),&#10;),&#10;body: $body$&#10;);" description="New Scaffold with AppBar" toReformat="false" toShortenFQNames="true">
6993
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
7094
<variable name="body" expression="&quot;bodyWidget&quot;" defaultValue="" alwaysStopAt="true" />
7195
<context>
7296
<option name="DART_STATEMENT" value="true" />
7397
</context>
7498
</template>
75-
99+
<!-- New Scaffold with AppBar and Fab-->
76100
<template name="scfAppBarFab" value="int _index = 0; // Make sure this is outside build(), otherwise every setState will chage the value back to 0 &#10;&#10;return Scaffold(&#10;appBar: AppBar(&#10; title: Text('$appbarTitle$'),&#10;),&#10;body: Center(&#10;child: Container(child: Text('You tapped the FAB $_index times')),&#10;),&#10;floatingActionButton: FloatingActionButton(&#10;onPressed: () =&gt; setState(() {&#10;_index++;&#10;}),&#10;tooltip: 'Increment Counter',&#10;child: Icon(Icons.add), //Change Icon&#10;),&#10;floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, //Change for different locations&#10;);" description="New Scaffold with AppBar and Fab" toReformat="false" toShortenFQNames="true">
77101
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
78102
<context>
79103
<option name="DART_STATEMENT" value="true" />
80104
</context>
81105
</template>
82-
106+
<!-- New Scaffold with AppBar and Bottom Nav Bar-->
83107
<template name="scfAppBarBtmNav" value="int _index = 0; // Make sure this is outside build(), otherwise every setState will chage the value back to 0 &#10;&#10;return Scaffold(&#10;appBar: AppBar(&#10;title: Text('$appbarTitle$'),&#10;),&#10;body: Center(&#10;child: Container(child: Text('You are looking at the message for bottom navigation item $_index')),&#10;),&#10;bottomNavigationBar: BottomNavigationBar(&#10;onTap: (tappedItemIndex) =&gt; setState(() {&#10;_index = tappedItemIndex;&#10; }),&#10;currentIndex: _index,&#10;items: [&#10;BottomNavigationBarItem(icon: Icon(Icons.av_timer), title: Text('$navBarItem1Text$')),&#10;BottomNavigationBarItem(icon: Icon(Icons.add), title: Text('$navBarItem2Text$'))&#10;])&#10;);" description="New Scaffold with AppBar &amp; Bottom Nav Bar" toReformat="false" toShortenFQNames="true">
84108
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
85109
<variable name="navBarItem1Text" expression="&quot;navBarItem1Text&quot;" defaultValue="" alwaysStopAt="true" />
@@ -88,5 +112,4 @@
88112
<option name="DART_STATEMENT" value="true" />
89113
</context>
90114
</template>
91-
92115
</templateSet>

0 commit comments

Comments
 (0)