- Flutter Snippets Plugin for Android Studio and IntelliJ IDEA
- Awesome flutter snippets android studio как добавить
- About
- How to add code snippets in Android Studio IDE?
- 5 Answers 5
- Browse the current Live Templates
- Use a Live Template
- Make you own Live Template
- Further Study
- Awesome Flutter Snippets
- Neevash Ramdial
- Awesome Flutter Snippets
- Features
- Requirements
- Known Issues
- Release Notes
Flutter Snippets Plugin for Android Studio and IntelliJ IDEA
May 31, 2019 · 2 min read
Edit: 21st February 2020 — A significant overhaul of the shortcuts has taken place in version 1.0.0 to bring this plugin in line with Awesome Flutter Snippets (Microsoft Code plugin).
Since attending Flutter Live ’18 and using Flutter to build my university dissertation I have fallen in love with Flutter. However, my biggest gripe is having to type the same thing over and over again, especially when it means I have to remember it! If only there was a plugin with Flutter live templates.
I found a live template plugin for Visual Stud i o Code, Awesome Flutter Snippets (AFS). The only problem is Visual Studio Code and I just don’t get along! I have been using JetBrains products for over 7 years and did not really want to change, given how familiar I am with the JetBrains tooling. Not to worry, I am sure there is an Android Studio/IntelliJ equivalent to AFS, there wasn’t…until now!
As a result, I built my first JetBrains plugin and in a few evenings, Flutter Snippets (FS) was born, supporting Android Studio and all editions of IntelliJ, see below for available snippets (this will update as I add more live templates). Download link:
Источник
Awesome flutter snippets android studio как добавить
Awesome Flutter Snippets
Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development by eliminating most of the boilerplate code associated with creating a widget. Widgets such as StreamBuilder and SingleChildScrollView can be created by typing the shortcut streamBldr and singleChildSV respectively.
- Speeds up development
- Eliminates boilerplate
- Supports complex widgets (Eg: Custom Clipper and Custom Paint)
Shortcut | Expanded | Description |
---|---|---|
statelessW | Stateless Widget | Creates a Stateless widget |
statefulW | Stateful Widget | Creates a Stateful widget |
build | Build Method | Describes the part of the user interface represented by the widget. |
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. |
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. |
reassemble | Reassemble | Called whenever the application is reassembled during debugging, for example during hot reload. |
didChangeD | didChangeDependencies | Called when a dependency of this State object changes |
didUpdateW | didUpdateWidget | Called whenever the widget configuration changes. |
customClipper | Custom Clipper | Used for creating custom shapes |
customPainter | Custom Painter | Used for creating custom paint |
listViewB | 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. |
listViewS | ListView.Separated | Creates a fixed-length scrollable linear array of list ‘items’ separated by list item ‘separators’. |
gridViewB | GridView.Builder | Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null itemCount improves the ability of the GridView to estimate the maximum scroll extent. |
gridViewC | GridView.Count | Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis. |
gridViewE | GridView.Extent | Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent. |
customScrollV | Custom ScrollView | Creates a ScrollView that creates custom scroll effects using slivers. If the primary argument is true, the controller must be null. |
streamBldr | Stream Builder | Creates a new StreamBuilder that builds itself based on the latest snapshot of interaction with the specified stream |
animatedBldr | Animated Builder | Creates an Animated Builder. The widget specified to child is passed to the builder |
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. |
orientationBldr | Orientation Builder | Creates a builder which allows for the orientation of the device to be specified and referenced |
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. |
singleChildSV | Single Child Scroll View | Creates a scroll view with a single child |
futureBldr | Future Builder | Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future. |
nosm | No Such Method | This method is invoked when a non-existent method or property is accessed. |
inheritedW | Inherited Widget | Class used to propagate information down the widget tree. |
mounted | Mounted | Whether this State object is currently in a tree. |
snk | Sink | A Sink is the input of a stream. |
strm | Stream | A source of asynchronous data events. A stream can be of any data type. |
subj | Subject | A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream. |
toStr | To String | Returns a string representation of this object. |
debugP | Debug Print | Prints a message to the console, which you can access using the flutter tool’s logs command (flutter logs). |
importM | Material Package | Import Material package. |
importC | Cupertino Package | Import Cupertino package. |
importFT | flutter_test Package | Import flutter_test package. |
mateapp | Material App | Create a new Material App. |
cupeapp | Cupertino Package | Create a New Cupertino App. |
tweenAnimationBuilder | Tween Animation Builder | Widget builder that animates a property of a Widget to a target value whenever the target value changes. |
valueListenableBuilder | 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. |
f-test | Test | Create a test function. |
widgetTest | Test Widgets | Create a testWidgets function. |
At this time, there are no known issues. If you discover a bug or would like to see a shortcut added, please create a pull request at our GitHub page.
- Removed trailing whitespaces (Thank you @leoshusar)
- Make widgets default to Container only (Thank you @Ascenio)
- Support for Listview.builder
- Support for GridView.count
- Support for GridView.extent
- Update all widgets to null safety
- Update engine to 1.56.0
- Add Flutter test import (Thank you @arthurdenner https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/16)
- Support for unit and widget test functions (Thank you @TNorbury https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/20)
- Added support for Listview.Separated (Thank you @timilehinjegede https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/26)
- Fixed inheritedW (Thank you @ianwith https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/22)
- Support for BehaviorSubject (Thanks @sinadarvi https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/7)
- Support for TweenAnimationBuilder
- Support for ValueListenableBuilder
- Fixed various bug fixes and typos
- Removed Stateful and Statless Widget since they are included with DartCode.
- Added Material App.
- Added Cupertino App.
- Changed prefixes to use a keyword associated with the widget/function (in camel case)
- Bug fixes
- Added support for debug print
- Added support for to string
- Added support for importing Cupertino package
- Added support for importing Material package (PR #2)
- Added child logic to Stateless and Stateful widgets snippets (PR #3)
Critical bug fixes:
- Adjusted tab stops to improve efficiency and workflow
- Removed blank Containers from builders in favor of a tab stop with semi-colon
- Added trailing comma at the end of child parameter
- Fixed formatting
- Removed unused tabs
- Corrected spelling errors
Added support for:
- Stream
- Sink
- Inherited Widget
- Mounted
- NoSuchMethod
Added support for:
- Stateful Builder
- Orientation Builder
- Layout Builder
- Single Child Scroll View
- Future Builder
Added support for:
- Stream Builder
- Animated Builder
- Custom Scroll View
- Listview.Builder
Initial release of Awesome Flutter Snippets
About
Awesome Flutter Snippets is a collection snippets and shortcuts for commonly used Flutter functions and classes
Источник
How to add code snippets in Android Studio IDE?
does anyone know how to add code snippets in Android Studio IDE? I didn’t found a menu entry or something like this.
I also want to know is it possible to change the existing snippets?
5 Answers 5
To add/edit templates:
On the menu choose File -> Settings , then under IDE Settings (or Editor ) go to Live Templates .
To insert a template:
On the menu choose Code -> Insert Live Template (or use it’s assigned shortcut key).
Screenshot Android Studio 3.4
Code snippets are known as Live Templates in Android Studio
Browse the current Live Templates
Go to File > Settings > Editor > Live Templates. Then click on the different options to see what they do.
Here are some interesting ones:
The words surrounded by $ signs are places where things will be filled in automatically from the context or where the user can tab through to fill them in.
Use a Live Template
Just type in the abbreviation and tab through anything that you need to fill in.
and I’m given this
with the cursor located at the position I marked with the vertical line | .
Make you own Live Template
Just write the code, highlight it, and go to Tools > Save as Live Template.
Further Study
Go to Settings (File > Settings, or CTRL ALT + S ) then search for «Live Templates».
A template screen will be opened. You can see here all live templates and you can also create your own custom live templates.
It is important that you choose the correct template group to define your new template (e.g. «Android»).
As an example, I will define a Toast method as a live template.
You can also click «use static import as possible» not to be handle importing stuff.
Источник
Awesome Flutter Snippets
Neevash Ramdial
Awesome Flutter Snippets
Awesome Flutter Snippets is a collection of commonly used Flutter classes and methods. It increases your speed of development by eliminating most of the boilerplate code associated with creating a widget. Widgets such as StreamBuilder and SingleChildScrollView can be created by typing the shortcut streamBldr and singleChildSV respectively.
Features
- Speeds up development
- Eliminates boilerplate
- Supports complex widgets (Eg: Custom Clipper and Custom Paint)
Shortcut | Expanded | Description |
---|---|---|
statelessW | Stateless Widget | Creates a Stateless widget |
statefulW | Stateful Widget | Creates a Stateful widget |
build | Build Method | Describes the part of the user interface represented by the widget. |
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. |
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. |
reassemble | Reassemble | Called whenever the application is reassembled during debugging, for example during hot reload. |
didChangeD | didChangeDependencies | Called when a dependency of this State object changes |
didUpdateW | didUpdateWidget | Called whenever the widget configuration changes. |
customClipper | Custom Clipper | Used for creating custom shapes |
customPainter | Custom Painter | Used for creating custom paint |
listViewB | 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. |
listViewS | ListView.Separated | Creates a fixed-length scrollable linear array of list ‘items’ separated by list item ‘separators’. |
gridViewB | GridView.Builder | Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null itemCount improves the ability of the GridView to estimate the maximum scroll extent. |
gridViewC | GridView.Count | Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis. |
gridViewE | GridView.Extent | Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent. |
customScrollV | Custom ScrollView | Creates a ScrollView that creates custom scroll effects using slivers. If the primary argument is true, the controller must be null. |
streamBldr | Stream Builder | Creates a new StreamBuilder that builds itself based on the latest snapshot of interaction with the specified stream |
animatedBldr | Animated Builder | Creates an Animated Builder. The widget specified to child is passed to the builder |
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. |
orientationBldr | Orientation Builder | Creates a builder which allows for the orientation of the device to be specified and referenced |
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. |
singleChildSV | Single Child Scroll View | Creates a scroll view with a single child |
futureBldr | Future Builder | Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future. |
nosm | No Such Method | This method is invoked when a non-existent method or property is accessed. |
inheritedW | Inherited Widget | Class used to propagate information down the widget tree. |
mounted | Mounted | Whether this State object is currently in a tree. |
snk | Sink | A Sink is the input of a stream. |
strm | Stream | A source of asynchronous data events. A stream can be of any data type. |
subj | Subject | A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream. |
toStr | To String | Returns a string representation of this object. |
debugP | Debug Print | Prints a message to the console, which you can access using the flutter tool’s logs command (flutter logs). |
importM | Material Package | Import Material package. |
importC | Cupertino Package | Import Cupertino package. |
importFT | flutter_test Package | Import flutter_test package. |
mateapp | Material App | Create a new Material App. |
cupeapp | Cupertino Package | Create a New Cupertino App. |
tweenAnimationBuilder | Tween Animation Builder | Widget builder that animates a property of a Widget to a target value whenever the target value changes. |
valueListenableBuilder | 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. |
f-test | Test | Create a test function. |
widgetTest | Test Widgets | Create a testWidgets function. |
Requirements
Known Issues
At this time, there are no known issues. If you discover a bug or would like to see a shortcut added, please create a pull request at our GitHub page.
Release Notes
- Removed trailing whitespaces (Thank you @leoshusar)
- Make widgets default to Container only (Thank you @Ascenio)
- Support for Listview.builder
- Support for GridView.count
- Support for GridView.extent
- Update all widgets to null safety
- Update engine to 1.56.0
- Add Flutter test import (Thank you @arthurdenner https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/16)
- Support for unit and widget test functions (Thank you @TNorbury https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/20)
- Added support for Listview.Separated (Thank you @timilehinjegede https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/26)
- Fixed inheritedW (Thank you @ianwith https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/22)
- Support for BehaviorSubject (Thanks @sinadarvi https://github.com/Nash0x7E2/awesome-flutter-snippets/pull/7)
- Support for TweenAnimationBuilder
- Support for ValueListenableBuilder
- Fixed various bug fixes and typos
- Removed Stateful and Statless Widget since they are included with DartCode.
- Added Material App.
- Added Cupertino App.
- Changed prefixes to use a keyword associated with the widget/function (in camel case)
- Bug fixes
- Added support for debug print
- Added support for to string
- Added support for importing Cupertino package
- Added support for importing Material package (PR #2)
- Added child logic to Stateless and Stateful widgets snippets (PR #3)
Critical bug fixes:
- Adjusted tab stops to improve efficiency and workflow
- Removed blank Containers from builders in favor of a tab stop with semi-colon
- Added trailing comma at the end of child parameter
- Fixed formatting
- Removed unused tabs
- Corrected spelling errors
Added support for:
- Stream
- Sink
- Inherited Widget
- Mounted
- NoSuchMethod
Added support for:
- Stateful Builder
- Orientation Builder
- Layout Builder
- Single Child Scroll View
- Future Builder
Added support for:
- Stream Builder
- Animated Builder
- Custom Scroll View
- Listview.Builder
Initial release of Awesome Flutter Snippets
Источник