Last active
June 8, 2021 14:35
-
-
Save yuva-dev/e63a23fa596a367a4ce046660a19b38e to your computer and use it in GitHub Desktop.
Android Studio template to automatically create dart object classes using json serializable, json annotation and build runner. Courtesy of @buntagonalprism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set( $nameparts = $NAME.split("_")) | |
#set( $namepart = '') | |
#set( $classname = '') | |
#foreach( $namepart in $nameparts ) | |
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1)) | |
#end | |
import 'package:json_annotation/json_annotation.dart'; | |
part #[[']]#$NAME#[[.g.dart']]#; | |
@JsonSerializable() | |
class $classname { | |
$classname(); | |
factory $classname#[[.fromJson(Map<String, dynamic> json) => _$]]#${classname}FromJson(json); | |
#[[Map<String, dynamic> toJson() => _$]]#${classname}ToJson(this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment