Skip to content

Commit

Permalink
[Breaking Change] - Alignment with Awesome Flutter Snippets (#5)
Browse files Browse the repository at this point in the history
* [Breaking Changes] - A overhaul to bring us in line with the VS plugin and make shortcuts consistent

* Add subj as per #4

* Make Gradle
  • Loading branch information
georgeherby authored Feb 21, 2020
1 parent 4ad5471 commit 4ba859d
Show file tree
Hide file tree
Showing 15 changed files with 775 additions and 355 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/flutter-snippets.zip
/.idea/
/out/
/*.dart
/*.dart
gradle.properties
.gradle/
gradle/
75 changes: 49 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,56 @@

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


## Available Snippets
| Shortcut| Flutter Docs| Description|
| ---------- | ------------------------ | -------------- |
|`alertDialog`|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|Creates a showDialog that returns with AlertDialog|
|`animBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/AnimationBuilder-class.html)|Creates an AnimationBuilder|
|`aspectRatio`|[View Docs](https://api.flutter.dev/flutter/widgets/AspectRatio-class.html)|Creates an AspectRatio|
|`column`|[View Docs](https://docs.flutter.io/flutter/widgets/Column-class.html)|Creates a Column Widget|
|`container`|[View Docs](https://docs.flutter.io/flutter/widgets/Container-class.html)|Creates a Container Widget|
|`customClipper`|[View Docs](https://api.flutter.dev/flutter/rendering/CustomClipper-class.html)|Creates a CustomClipper|
|`customPainter`|[View Docs](https://api.flutter.dev/flutter/rendering/CustomPainter-class.html)|Creates a CustomPainter|
|`customScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html)|Creates a CustomScrollView|
|`futureBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/FutureBuilder-class.html)|Creates a FutureBuilder|
|`importMat`|[View Docs](https://api.flutter.dev/flutter/material/material-library.html)|Adds Material Import|
|`importCup`|[View Docs](https://api.flutter.dev/flutter/cupertino/cupertino-library.html)|Adds Cupertino Import|
|`layoutBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/LayoutBuilder-class.html)|Creates a LayoutBuilder|
|`listViewBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/ListView.builder.html)|Creates a ListView.builder()|
|`orienatatBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/OrientationBuilder-class.html)|Creates a OrientationBuilder|
|`row`|[View Docs](https://docs.flutter.io/flutter/widgets/Row-class.html)|Creates a Row Widget|
|`scfAll`|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|
|`scfAppBar`| |Creates a Scaffold containing an Appbar|
|`scfAppBarFab`| |Creates a Scaffold containing an Appbar and Floating Action Button|
|`scfAppBarBtmNav`| |Creates a Scaffold containing an Appbar and Bottom Navigation Bar|
|`singleChildScrollV`|[View Docs](https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html)|Creates a SingleChildScrollView|
|`streamBldr`|[View Docs](https://docs.flutter.io/flutter/widgets/StreamBuilder-class.html)|Creates a StreamBuilder|
|`stfulBldr`|[View Docs](https://api.flutter.dev/flutter/widgets/StatefulBuilder/StatefulBuilder.html)|Creates a StatefulBuilder|
|`text`|[View Docs](https://docs.flutter.io/flutter/widgets/Text-class.html)|Creates a Text Widget|
### Generic
| Shortcut|Expanded|Description|Flutter Docs|
| ---------- | ----------| -------------- | -------------- |
|`alertDialog`|Alert Dialog |Creates a showDialog that returns with AlertDialog|[View Docs](https://docs.flutter.io/flutter/widgets/AlertDialog-class.html)|
|`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)|
|`aspectRatio`| AspectRatio |Creates an AspectRatio|[View Docs](https://api.flutter.dev/flutter/widgets/AspectRatio-class.html)|
|`build`|Build Method|Describes the part of the user interface represented by the widget.| |
|`column`| Column |Creates a Column Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Column-class.html)|
|`container`| Container |Creates a Container Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Container-class.html)|
|`customClipper`|Custom Clipper|Used for creating custom shapes|[View Docs](https://api.flutter.dev/flutter/rendering/CustomClipper-class.html)|
|`customPainter`|Custom Painter|Used for creating custom paint|[View Docs](https://api.flutter.dev/flutter/rendering/CustomPainter-class.html)|
|`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)|
|`debugP`|Debug Print|Prints a message to the console, which you can access using the flutter tool'slogscommand (flutter logs).|[View Docs](https://api.flutter.dev/flutter/foundation/debugPrint.html)|
|`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)|
|`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)|
|`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)|
|`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)|
|`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)|
|`mounted`|Mounted|Whether this State object is currently in a tree.|[View Docs](https://api.flutter.dev/flutter/widgets/State/mounted.html)|
|`nosm`|No Such Method|This method is invoked when a non-existent method or property is accessed.|[View Docs](https://api.flutter.dev/flutter/dart-core/Object/noSuchMethod.htmll)|
|`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)|
|`reassemble`|Reassemble|Called whenever the application is reassembled during debugging, for example during hot reload.|[View Docs](https://api.flutter.dev/flutter/widgets/State/reassemble.html)|
|`row`| |Creates a Row Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Row-class.html)|
|`singleChildSV`|Single Child Scroll View|Creates a scroll view with a single child|[View Docs](https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html)|
|`snk`|Sink|A Sink is the input of a stream.|[View Docs](https://api.dartlang.org/stable/dart-async/StreamController-class.html)|
|`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)|
|`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)|
|`strm`|StreamController|A source of asynchronous data events. A stream can be of any data type.|[View Docs](https://api.dartlang.org/stable/dart-async/StreamController-class.html)|
|`subj`|BehaviorSubject|A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream.|[View Docs](https://pub.dev/documentation/rxdart/latest/rx/BehaviorSubject-class.html)|
|`txt`| Text |Creates a Text Widget|[View Docs](https://docs.flutter.io/flutter/widgets/Text-class.html)|
|`toStr`|To String|Returns a string representation of this object.|[View Docs](https://docs.flutter.io/flutter/widgets/Text-class.html)|
|`tweenAnimationBldr`|Tween Animation Builder|Widget builder that animates a property of a Widget to a target value whenever the target value changes.|[View Docs](https://api.flutter.dev/flutter/animation/Tween-class.html)|
|`valueListenableBldr`|Value Listenable Builder |Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes.|[View Docs](https://api.flutter.dev/flutter/widgets/ValueListenableBuilder-class.html)|

### Cupertino Specific
| Shortcut| Expanded | Description| Flutter Docs |
| ---------- | ------------------------ | -------|------------- |
|`cupeApp`|Cupertino App |Create a New Cupertino App| [View Docs](https://api.flutter.dev/flutter/cupertino/CupertinoApp-class.html)|
|`importC`| Cupertino Package|Import Cupertino package.| [View Docs](https://api.flutter.dev/flutter/cupertino/cupertino-library.html)|
### Material Specific
| Shortcut| Expanded | Description| Flutter Docs |
| ---------- | ------------------------ | -------|------------- |
|`importM`| Material Package |Import Material package|[View Docs](https://api.flutter.dev/flutter/material/material-library.html)|
|`mateApp`| Material App |Create a new Material App|[View Docs](https://api.flutter.dev/flutter/material/MaterialApp-class.html) |
|`scfAll`| Scaffold |Creates a Scaffold containing an Appbar, BottomNavigationBar and FloatingActionButton|[View Docs](https://docs.flutter.io/flutter/material/Scaffold-class.html)|
|`scfAppBar`| Scaffold |Creates a Scaffold containing an Appbar| |
|`scfAppBarFab`| Scaffold |Creates a Scaffold containing an Appbar and Floating Action Button| |
|`scfAppBarBtmNav`| Scaffold |Creates a Scaffold containing an Appbar and Bottom Navigation Bar||


## Plugin Supports the Following IDEs:
* Android Studio
Expand Down
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.4.13'
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'idea'

group 'com.herbert.george.flutter-snippets'
version "$version-$releaseChannel-$iteration"
sourceCompatibility = javaVersion
repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}

sourceSets {
main {
java.srcDirs 'src', 'gen'
resources.srcDir 'resources'
}
}

intellij {
plugins 'java', "Dart:$dartVersion"
version ideaVersion
type ideaType
pluginName pluginName
downloadSources Boolean.valueOf(sources)
updateSinceUntilBuild false
sameSinceUntilBuild true
patchPluginXml {
version project.version
changeNotes "[Breaking Changes] - Read the README for changes https://github.com/georgeherby/flutter-snippets/blob/master/README.md. A overhaul to bring us in line with the VS plugin and make shortcuts consistent"
sinceBuild pluginSinceBuild
}
}

publishPlugin {
channels releaseChannel
token intellijToken
}
14 changes: 0 additions & 14 deletions flutter-snippets.iml

This file was deleted.

172 changes: 172 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#!/usr/bin/env sh

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
echo "$*"
}

die () {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
Loading

0 comments on commit 4ba859d

Please sign in to comment.