Skip to content

Commit 0562830

Browse files
committed
Add support for animBldr (Animation Builder) and a few various Scaffold options (scfAppBar, scfAppBarFab and scfAppBarBtmNav)
1 parent 708c3b7 commit 0562830

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

.gitignore

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

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
# Flutter Snippets
2-
An Intellij & Android Studio plugin that adds Live Templates to your IDE saving time writing the boiler plate in Flutter.
2+
An Intellij & Android Studio plugin that adds Live Templates to your IDE saving time writing the boilerplate in Flutter.
33

44

55
## Available Snippets
66
| Shortcut| Flutter Docs| Description|
77
| ---------- | ------------------------ | -------------- |
88
|`alertDialog`|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|Creates a showDialog that returns with AlertDialog|
9+
|`animBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/AnimationBuilder-class.html)|Creates an AnimationBuilder|
910
|`futureBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html)|Creates a FutureBuilder|
1011
|`listViewBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/ListView.builder.html)|Creates a ListView.builder()|
1112
|`scfAll`|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|
13+
|`scfAppBar`| |Creates a Scaffold containing an Appbar|
14+
|`scfAppBarFab`| |Creates a Scaffold containing an Appbar and Floating Action Button|
15+
|`scfAppBarBtmNav`| |Creates a Scaffold containing an Appbar and Bottom Navigation Bar|
1216
|`streamBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/StreamBuilder-class.html)|Creates a StreamBuilder|
1317

1418
## Plugin Supports the Following IDEs:
19+
* Android Studio
1520
* IntelliJ IDEA Ultimate
1621
* IntelliJ IDEA Community
1722
* IntelliJ IDEA Educational
18-
* Android Studio
23+

resources/META-INF/plugin.xml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<idea-plugin>
23
<id>com.herbert.george.flutter-snippets</id>
34
<name>Flutter Snippets</name>
4-
<version>0.1.1</version>
5+
<version>0.1.2</version>
56
<vendor>George Herbert</vendor>
67
<description><![CDATA[
7-
Provides live templates for Flutter to save time writing boiler plate.<br><br>
8-
9-
The following commands are supported:
8+
<p>Provides live templates for Flutter to save time writing boilerplate.</p>
9+
The following commands are supported:
1010
<table>
1111
<tr>
1212
<th>Shortcut</th>
@@ -15,6 +15,10 @@
1515
<tr>
1616
<td>alertDialog</td>
1717
<td>Creates a showDialog that returns with AlertDialog</td>
18+
</tr>
19+
<tr>
20+
<td>animBldr</td>
21+
<td>Creates an AnimationBuilder</td>
1822
</tr>
1923
<tr>
2024
<td>futureBldr</td>
@@ -27,19 +31,29 @@
2731
<tr>
2832
<td>scfAll</td>
2933
<td>Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton</td>
34+
</tr>
35+
<tr>
36+
<td>scfAppBar</td>
37+
<td>Creates a Scaffold containing an Appbar</td>
38+
</tr>
39+
<tr>
40+
<td>scfAppBarFab</td>
41+
<td>Creates a Scaffold containing an Appbar and Floating Action Button</td>
42+
</tr>
43+
<tr>
44+
<td>scfAppBarBtmNav</td>
45+
<td>Creates a Scaffold containing an Appbar and Bottom Navigation Bar</td>
3046
</tr>
3147
<tr>
3248
<td>streamBldr</td>
3349
<td>Creates a StreamBuilder</td>
3450
</tr>
35-
</table>
36-
37-
]]></description>
38-
<change-notes>Add support for (scfAll) scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton. Other scaffold templates will follow</change-notes>
39-
<idea-version since-build="141.0"/>
51+
</table>]]></description>
52+
<change-notes>Add support for animBldr (Animation Builder) and a few various Scaffold options (scfAppBar, scfAppBarFab and scfAppBarBtmNav)</change-notes>
53+
<idea-version since-build="141.0" />
4054
<depends>com.intellij.modules.java</depends>
4155
<extensions defaultExtensionNs="com.intellij">
42-
<defaultLiveTemplatesProvider implementation="FlutterTemplateProvider"/>
43-
<liveTemplateContext implementation="FlutterContext"/>
56+
<defaultLiveTemplatesProvider implementation="FlutterTemplateProvider" />
57+
<liveTemplateContext implementation="FlutterContext" />
4458
</extensions>
4559
</idea-plugin>

resources/liveTemplates/Flutter.xml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<templateSet group="Flutter">
3+
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">
5+
<variable name="animationController" expression="&quot;animationController&quot;" defaultValue="" alwaysStopAt="true" />
6+
<variable name="childWidget" expression="&quot;childWidget&quot;" defaultValue="" alwaysStopAt="true" />
7+
<variable name="buildWidget" expression="&quot;buildWidget&quot;" defaultValue="" alwaysStopAt="true" />
8+
<context>
9+
<option name="DART_STATEMENT" value="true" />
10+
</context>
11+
</template>
12+
313
<template name="futureBldr"
414
value="FutureBuilder(&#10;future: $FUTURE$,initialData: $INITIAL$,builder: (BuildContext context, AsyncSnapshot snapshot) {if (snapshot.hasData) {if (snapshot.data!=null) {return $WIDGET$;} else {return CircularProgressIndicator();}}),"
515
description="Create FutureBuilder" toReformat="true" toShortenFQNames="true">
@@ -10,8 +20,9 @@
1020
<option name="DART_STATEMENT" value="true"/>
1121
</context>
1222
</template>
23+
1324
<template name="streamBldr"
14-
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}, ),"
25+
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}, ),"
1526
description="Create StreamBuilder" toReformat="true" toShortenFQNames="true">
1627
<variable name="STREAM" expression="&quot;stream&quot;" defaultValue="" alwaysStopAt="true"/>
1728
<variable name="DEFAULTWIDGET" expression="&quot;ConnectionNone&quot;" defaultValue="" alwaysStopAt="true"/>
@@ -31,6 +42,7 @@
3142
<option name="DART_STATEMENT" value="true"/>
3243
</context>
3344
</template>
45+
3446
<template name="showDialog"
3547
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;);"
3648
description="New AlertDialog" toReformat="false" toShortenFQNames="true">
@@ -43,7 +55,8 @@
4355
<option name="DART_STATEMENT" value="true"/>
4456
</context>
4557
</template>
46-
<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 AlertDialog" toReformat="false" toShortenFQNames="true">
58+
59+
<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">
4760
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
4861
<variable name="navBarItem1Text" expression="&quot;navBarItem1Text&quot;" defaultValue="" alwaysStopAt="true" />
4962
<variable name="navBarItem2Text" expression="&quot;navBarItem2Text&quot;" defaultValue="" alwaysStopAt="true" />
@@ -52,8 +65,28 @@
5265
</context>
5366
</template>
5467

68+
<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">
69+
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
70+
<variable name="body" expression="&quot;bodyWidget&quot;" defaultValue="" alwaysStopAt="true" />
71+
<context>
72+
<option name="DART_STATEMENT" value="true" />
73+
</context>
74+
</template>
5575

76+
<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">
77+
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
78+
<context>
79+
<option name="DART_STATEMENT" value="true" />
80+
</context>
81+
</template>
5682

57-
83+
<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">
84+
<variable name="appbarTitle" expression="&quot;appbarTitle&quot;" defaultValue="" alwaysStopAt="true" />
85+
<variable name="navBarItem1Text" expression="&quot;navBarItem1Text&quot;" defaultValue="" alwaysStopAt="true" />
86+
<variable name="navBarItem2Text" expression="&quot;navBarItem2Text&quot;" defaultValue="" alwaysStopAt="true" />
87+
<context>
88+
<option name="DART_STATEMENT" value="true" />
89+
</context>
90+
</template>
5891

5992
</templateSet>

0 commit comments

Comments
 (0)