Skip to content

Instantly share code, notes, and snippets.

@8thgencore
Created December 18, 2021 19:16
Show Gist options
  • Select an option

  • Save 8thgencore/03cbb5813193ac50b1caee91fc1ef97f to your computer and use it in GitHub Desktop.

Select an option

Save 8thgencore/03cbb5813193ac50b1caee91fc1ef97f to your computer and use it in GitHub Desktop.
add to C:\Users\User\AppData\Roaming\Google\AndroidStudio[version]\templates
<templateSet group="Dart">
<template name="json_class" value="import 'package:json_annotation/json_annotation.dart';&#10;&#10;part '$class_name_snake_case$.g.dart';&#10;&#10;@JsonSerializable(fieldRename: FieldRename.snake)&#10;class $ClassName$ {&#10;&#10; factory $ClassName$.fromJson(final Map&lt;String, dynamic&gt; json) =&gt; _$$$ClassName$FromJson(json);&#10; &#10; Map&lt;String, dynamic&gt; toJson() =&gt; _$$$ClassName$ToJson(this);&#10; &#10;}" description="Create new JsonSerializable model class" toReformat="false" toShortenFQNames="true">
<variable name="ClassName" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="class_name_snake_case" expression="snakeCase(ClassName)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="DART_TOPLEVEL" value="true" />
</context>
</template>
<template name="scon" value="static $ClassName$? _instance;&#10;&#10;factory $ClassName$.getInstance() =&gt; _instance ?? $ClassName$._internal();&#10;&#10;$ClassName$._internal();" toReformat="false" toShortenFQNames="true">
<variable name="ClassName" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="DART" value="true" />
<option name="DART_STATEMENT" value="false" />
</context>
</template>
</templateSet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment