decodeDateTimeTickProviderSpec static method

DateTimeTickProviderSpec? decodeDateTimeTickProviderSpec(
  1. dynamic map, {
  2. bool validate = true,
})

Decodes the object from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "includeTime": <bool>,
  "type": "auto"
}

Implementation

static common.DateTimeTickProviderSpec? decodeDateTimeTickProviderSpec(
  dynamic map, {
  bool validate = true,
}) {
  common.DateTimeTickProviderSpec? result;

  if (map is common.DateTimeTickProviderSpec) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/date_time_tick_provider_spec',
      value: map,
      validate: validate,
    ));
    final type = map['type'];

    switch (type) {
      case 'auto':
        result = common.AutoDateTimeTickProviderSpec(
          includeTime: JsonClass.parseBool(
            map['includeTime'],
            whenNull: true,
          ),
        );
        break;

      default:
        throw Exception(
          '[decodeDateTimeTickProviderSpec]: unknown type encountered: [$type]',
        );
    }
  }

  return result;
}