decodeOutsideJustification static method

OutsideJustification? decodeOutsideJustification(
  1. dynamic map, {
  2. bool validate = true,
})

Expects the map to be either a charts.OutsideJustification or a String containing one of the following values:

  • end
  • endDrawArea
  • middle
  • middleDrawArea
  • start
  • startDrawArea

Implementation

static charts.OutsideJustification? decodeOutsideJustification(
  dynamic map, {
  bool validate = true,
}) {
  charts.OutsideJustification? result;

  if (map is charts.OutsideJustification) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/outside_justification',
      value: map,
      validate: validate,
    ));
    switch (map) {
      case 'end':
        result = charts.OutsideJustification.end;
        break;

      case 'endDrawArea':
        result = charts.OutsideJustification.endDrawArea;
        break;

      case 'middle':
        result = charts.OutsideJustification.middle;
        break;

      case 'middleDrawArea':
        result = charts.OutsideJustification.middleDrawArea;
        break;

      case 'start':
        result = charts.OutsideJustification.start;
        break;

      case 'startDrawArea':
        result = charts.OutsideJustification.startDrawArea;
        break;

      default:
        throw Exception('Unknown [OutsideJustification] encountered: [$map]');
    }
  }

  return result;
}