decodeBehaviorPosition static method

BehaviorPosition? decodeBehaviorPosition(
  1. dynamic map, {
  2. bool validate = true,
})

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

  • bottom
  • end
  • inside
  • start
  • top

Implementation

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

  if (map is charts.BehaviorPosition) {
    result = map;
  } else if (map != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/behavior_position',
      value: map,
      validate: validate,
    ));

    switch (map) {
      case 'bottom':
        result = charts.BehaviorPosition.bottom;
        break;

      case 'end':
        result = charts.BehaviorPosition.end;
        break;

      case 'inside':
        result = charts.BehaviorPosition.inside;
        break;

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

      case 'top':
        result = charts.BehaviorPosition.top;
        break;

      default:
        throw Exception(
          '[decodeBehaviorPosition]: map is not supported: [$map]',
        );
    }
  }

  return result;
}