shapeBorder static method

ShapeBorder? shapeBorder(
  1. DataSource source,
  2. List<Object> key
)

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 ShapeBorder? shapeBorder(DataSource source, List<Object> key) {
  final List<ShapeBorder?>? shapes = list<ShapeBorder?>(source, key, shapeBorder);
  if (shapes != null) {
    return shapes.where((ShapeBorder? a) => a != null).reduce((ShapeBorder? a, ShapeBorder? b) => a! + b!);
  }
  final String? type = source.v<String>([...key, 'type']);
  switch (type) {
    case null:
      return null;
    case 'box':
      return border(source, [...key, 'sides']) ?? const Border();
    case 'beveled':
      return BeveledRectangleBorder(
        side: borderSide(source, [...key, 'side']) ?? BorderSide.none,
        borderRadius: borderRadius(source, [...key, 'borderRadius']) ?? BorderRadius.zero,
      );
    case 'circle':
      return CircleBorder(
        side: borderSide(source, [...key, 'side']) ?? BorderSide.none,
      );
    case 'continuous':
      return ContinuousRectangleBorder(
        side: borderSide(source, [...key, 'side']) ?? BorderSide.none,
        borderRadius: borderRadius(source, [...key, 'borderRadius']) ?? BorderRadius.zero,
      );
    case 'rounded':
      return RoundedRectangleBorder(
        side: borderSide(source, [...key, 'side']) ?? BorderSide.none,
        borderRadius: borderRadius(source, [...key, 'borderRadius']) ?? BorderRadius.zero,
      );
    case 'stadium':
      return StadiumBorder(
        side: borderSide(source, [...key, 'side']) ?? BorderSide.none,
      );
    default:
      final ArgumentDecoder<ShapeBorder>? decoder = shapeBorderDecoders[type];
      if (decoder == null) {
        return null;
      }
      return decoder(source, key);
  }
}