shapeBorder static method
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:
-
box
: the map'ssides
key is interpreted as a list by border and the resulting BoxBorder (actually, BorderDirectional) is returned. -
beveled
: a BeveledRectangleBorder is returned; theside
key is interpreted by borderSide to set the BeveledRectangleBorder.side (default of [BorderSide.none)), and theborderRadius
key is interpreted by borderRadius to set the BeveledRectangleBorder.borderRadius (default BorderRadius.zero). -
circle
: a CircleBorder is returned; theside
key is interpreted by borderSide to set the BeveledRectangleBorder.side (default of [BorderSide.none)). -
continuous
: a ContinuousRectangleBorder is returned; theside
key is interpreted by borderSide to set the BeveledRectangleBorder.side (default of [BorderSide.none)), and theborderRadius
key is interpreted by borderRadius to set the BeveledRectangleBorder.borderRadius (default BorderRadius.zero). -
rounded
: a RoundedRectangleBorder is returned; theside
key is interpreted by borderSide to set the BeveledRectangleBorder.side (default of [BorderSide.none)), and theborderRadius
key is interpreted by borderRadius to set the BeveledRectangleBorder.borderRadius (default BorderRadius.zero). -
stadium
: a StadiumBorder is returned; theside
key is interpreted by borderSide to set the BeveledRectangleBorder.side (default of [BorderSide.none)).
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);
}
}