All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dart.enum.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
class {{classname}} {
  /// The underlying value of this enum member.
  {{dataType}} value;

  {{classname}}._internal(this.value);

  {{#allowableValues}}
    {{#enumVars}}
      {{#description}}
  /// {{description}}
      {{/description}}
  static {{classname}} {{name}} = {{classname}}._internal({{{value}}});
    {{/enumVars}}
  {{/allowableValues}}

  {{classname}}.fromJson(dynamic data) {
    switch (data) {
    {{#allowableValues}}
      {{#enumVars}}
          case {{{value}}}: value = data; break;
      {{/enumVars}}
    {{/allowableValues}}
    default: throw('Unknown enum value to decode: $data');
    }
  }

  static dynamic encode({{classname}} data) {
    return data.value;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy