myConsciousness / freezer

🎯 This library automatically generates object classes from JSON files that can be parsed by the freezed library.

Home Page:https://pub.dev/packages/freezer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `@JsonValue` annotation for Enum value when value is specified

myConsciousness opened this issue · comments

1. What could be improved

Like:

{
  "enums": {
    "product_type": [
      {
        "name": "sweet",
        "value": 0
      }
    ]
  }
}
import 'package:json_annotation/json_annotation.dart';

enum ProductType {
    @JsonValue(0)
    sweet(0);

  final int value;

  const ProductType(this.value);
}

2. Why should this be improved

3. Any risks?

4. More information