shapeBorder static method

Map<String, dynamic>? shapeBorder(
  1. ShapeBorder? shapeBorder
)

Returns a ShapeBorder from the specified map or list.

If the key identifies a list, then each entry in the list is decoded by recursively invoking shapeBorder, and the result is the combination of those ShapeBorder values as obtained using the ShapeBorder.+ operator.

Otherwise, if the key identifies a map with a type value, the map is interpreted according to the type as follows:

If the type is none of these, then the type is looked up in shapeBorderDecoders, and if an entry is found, this method defers to that callback.

Otherwise, if type is null or is not found in shapeBorderDecoders, returns null.

Implementation

static Map<String, dynamic>? shapeBorder(ShapeBorder? shapeBorder) {
  if (shapeBorder == null) return null;

  switch (shapeBorder) {
    case Border():
      return NotNullMap.from({
        'type': 'box',
        'sides': border(shapeBorder),
      });
    case BeveledRectangleBorder():
      return NotNullMap.from({
        'type': 'beveled',
        'side': borderSide(shapeBorder.side),
        'borderRadius': borderRadius(shapeBorder.borderRadius),
      });
    case CircleBorder():
      return NotNullMap.from(
          {'type': 'circle', 'side': borderSide(shapeBorder.side)});
    case ContinuousRectangleBorder():
      return NotNullMap.from({
        'type': 'continuous',
        'size': borderSide(shapeBorder.side),
        'borderRadius': borderRadius(shapeBorder.borderRadius)
      });
    case StadiumBorder():
      return NotNullMap.from(
          {'type': 'stadium', 'side': borderSide(shapeBorder.side)});
    default:
      final encoder = shapeBorderEncoders[shapeBorder.runtimeType];
      if (encoder == null) return null;
      return encoder(shapeBorder);
  }
}