Skip to content

Instantly share code, notes, and snippets.

@ruan65
Last active March 1, 2019 14:10
Show Gist options
  • Save ruan65/6246d5042884c1b8bef3a5815133dfbb to your computer and use it in GitHub Desktop.
Save ruan65/6246d5042884c1b8bef3a5815133dfbb to your computer and use it in GitHub Desktop.
Android Studio Live Templates code snippets /home/a/.AndroidStudio3.3/config/templates/user.xml on Ubuntu /Users/a/Library/Preferences/AndroidStudio3.3/templates/user.xml on Mac
<templateSet group="user">
<template name="imf" value="import 'package:flutter/material.dart';" description="Import flutter material" toReformat="false" toShortenFQNames="true">
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="fblo" value="import 'dart:async';&#10;import 'package:bloc/bloc.dart';&#10;&#10;class $name$Bloc extends Bloc&lt;$event$, $state$&gt; {&#10;&#10;&#10; @override&#10; $name$State get initialState =&gt; null;&#10;&#10; @override&#10; Stream&lt;$name$State&gt; mapEventToState($state$ currentState, $event$ event) {&#10; $cursor$&#10; return null;&#10; }&#10;&#10;}" description="flutter bloc class template" toReformat="false" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="event" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="state" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="cursor" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="bvh" value="library $lib$;&#10;&#10;import 'dart:convert';&#10;&#10;import 'package:built_collection/built_collection.dart';&#10;import 'package:built_value/built_value.dart';&#10;import 'package:built_value/serializer.dart';&#10;&#10;part '$lib$.g.dart';" description="Built value header" toReformat="false" toShortenFQNames="true">
<variable name="lib" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="bvb" value="abstract class $className$ implements Built&lt;$className$, $className$Builder&gt; {&#10;&#10; String get brand;&#10;&#10; $className$._();&#10;&#10; factory $className$([updates($className$Builder b)]) = _${$className$};&#10;}" description="built value body" toReformat="false" toShortenFQNames="true">
<variable name="className" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="slw" value="import 'package:flutter/material.dart';&#10;&#10;class $class$Widget extends StatelessWidget {&#10; &#10; @override&#10; Widget build(BuildContext context) =&gt; $outer$(&#10; &#10; );&#10;}" description="Stateless widget" toReformat="false" toShortenFQNames="true">
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="outer" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="sfw" value="import 'package:flutter/material.dart';&#10;&#10;class $className$ extends StatefulWidget {&#10; @override&#10; State&lt;StatefulWidget&gt; createState() =&gt; _$className$State();&#10; &#10;}&#10;&#10;class _$className$State extends State&lt;$className$&gt; {&#10; &#10; @override&#10; Widget build(BuildContext context) =&gt; $widget$(&#10; &#10; );&#10; &#10;}" description="Flutter Statefull widget" toReformat="false" toShortenFQNames="true">
<variable name="className" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="widget" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="equ" value="import 'package:equatable/equatable.dart';&#10;&#10;abstract class $class$Event extends Equatable {&#10; $class$Event([List props = const []]) : super(props);&#10;}" description="Equatable abstract class for events" toReformat="false" toShortenFQNames="true">
<variable name="class" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
</context>
</template>
<template name="bv" value="abstract class $CLASS_NAME$ implements Built&lt;$CLASS_NAME$, $CLASS_NAME$Builder&gt; {&#10; $CLASS_NAME$._();&#10; factory $CLASS_NAME$([updates($CLASS_NAME$Builder b)]) = _$$$CLASS_NAME$;&#10;}" description="Built value class" toReformat="false" toShortenFQNames="true">
<variable name="CLASS_NAME" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART_TOPLEVEL" value="true" />
</context>
</template>
<template name="bvs" value="library serializers;&#10;&#10;import 'package:built_value/serializer.dart';&#10;import 'package:built_value/standard_json_plugin.dart';&#10;import 'package:built_collection/built_collection.dart';&#10;&#10;import 'article.dart';&#10;&#10;part 'serializers.g.dart';&#10;&#10;@SerializersFor(const [&#10; &#10;])&#10;final Serializers serializers = _$serializers;&#10;&#10;Serializers standardSerializers =&#10;(serializers.toBuilder()..addPlugin(StandardJsonPlugin())).build();" description="Build value serializers" toReformat="false" toShortenFQNames="true">
<context>
<option name="DART_TOPLEVEL" value="true" />
</context>
</template>
</templateSet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment