Attribute.fromJson constructor

Attribute.fromJson(
  1. Map<String, dynamic> json
)

Create an Attribute from a JSON object.

Implementation

factory Attribute.fromJson(Map<String, dynamic> json) {
  final key = json['key'] as String;
  final value = json['value'];

  return Attribute._(key, value);

  // if (value is String) {
  //   return Attribute.fromString(key, value);
  // } else if (value is bool) {
  //   return Attribute.fromBoolean(key, value);
  // } else if (value is double) {
  //   return Attribute.fromDouble(key, value);
  // // ignore: avoid_double_and_int_checks
  // } else if (value is int) {
  //   return Attribute.fromInt(key, value);
  // } else if (value is List<String>) {
  //   return Attribute.fromStringList(key, value);
  // } else if (value is List<bool>) {
  //   return Attribute.fromBooleanList(key, value);
  // } else if (value is List<double>) {
  //   return Attribute.fromDoubleList(key, value);
  // } else if (value is List<int>) {
  //   return Attribute.fromIntList(key, value);
  // } else {
  //   throw ArgumentError('Invalid attribute value type');
  // }
}