fromJson static method

GEOrderSchema? fromJson(
  1. dynamic value
)

Returns a new GEOrderSchema instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static GEOrderSchema? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'id'),
          'Required key "GEOrderSchema[id]" is missing from JSON.');
      assert(json[r'id'] != null,
          'Required key "GEOrderSchema[id]" has a null value in JSON.');
      assert(json.containsKey(r'type'),
          'Required key "GEOrderSchema[type]" is missing from JSON.');
      assert(json[r'type'] != null,
          'Required key "GEOrderSchema[type]" has a null value in JSON.');
      assert(json.containsKey(r'code'),
          'Required key "GEOrderSchema[code]" is missing from JSON.');
      assert(json[r'code'] != null,
          'Required key "GEOrderSchema[code]" has a null value in JSON.');
      assert(json.containsKey(r'quantity'),
          'Required key "GEOrderSchema[quantity]" is missing from JSON.');
      assert(json[r'quantity'] != null,
          'Required key "GEOrderSchema[quantity]" has a null value in JSON.');
      assert(json.containsKey(r'price'),
          'Required key "GEOrderSchema[price]" is missing from JSON.');
      assert(json[r'price'] != null,
          'Required key "GEOrderSchema[price]" has a null value in JSON.');
      assert(json.containsKey(r'created_at'),
          'Required key "GEOrderSchema[created_at]" is missing from JSON.');
      assert(json[r'created_at'] != null,
          'Required key "GEOrderSchema[created_at]" has a null value in JSON.');
      return true;
    }());

    return GEOrderSchema(
      id: mapValueOfType<String>(json, r'id')!,
      type: GEOrderType.fromJson(json[r'type'])!,
      account: mapValueOfType<String>(json, r'account'),
      code: mapValueOfType<String>(json, r'code')!,
      quantity: mapValueOfType<int>(json, r'quantity')!,
      price: mapValueOfType<int>(json, r'price')!,
      createdAt: mapDateTime(json, r'created_at', r'')!,
    );
  }
  return null;
}