dart-dio.class.mustache Maven / Gradle / Ivy
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
part '{{classFilename}}.g.dart';
abstract class {{classname}} implements Built<{{classname}}, {{classname}}Builder> {
{{#vars}}
{{#description}}
/// {{{description}}}
{{/description}}
{{#isNullable}}
@nullable
{{/isNullable}}
@BuiltValueField(wireName: r'{{baseName}}')
{{{datatypeWithEnum}}} get {{name}};
{{#allowableValues}}
// {{#min}}range from {{{min}}} to {{{max}}}{{/min}}{{^min}}enum {{name}}Enum { {{#values}} {{{.}}}, {{/values}} };{{/min}}
{{/allowableValues}}
{{/vars}}
// Boilerplate code needed to wire-up generated code
{{classname}}._();
static void _initializeBuilder({{{classname}}}Builder b) => b{{#vars}}{{#defaultValue}}
..{{{name}}} = {{#isEnum}}{{^isContainer}}const {{{classname}}}{{{enumName}}}._({{/isContainer}}{{/isEnum}}{{{defaultValue}}}{{#isEnum}}{{^isContainer}}){{/isContainer}}{{/isEnum}}{{/defaultValue}}{{/vars}};
factory {{classname}}([void updates({{classname}}Builder b)]) = _${{classname}};
static Serializer<{{classname}}> get serializer => _${{#lambda.camelcase}}{{{classname}}}{{/lambda.camelcase}}Serializer;
}
{{!
Generate an enum for any variables that are declared as inline enums
isEnum is only true for inline variables that are enums.
If an enum is declared as a definition, isEnum is false and the enum is generated from the
enum.mustache template.
}}
{{#vars}}
{{#isEnum}}
{{^isContainer}}
{{>enum_inline}}
{{/isContainer}}
{{#isContainer}}
{{#mostInnerItems}}
{{>enum_inline}}
{{/mostInnerItems}}
{{/isContainer}}
{{/isEnum}}
{{/vars}}