buttonShape static method
Implementation
static OutlinedBorder? buttonShape(
dynamic value, Color? Function(String) toColor) {
if (value == null) {
return null;
}
if (value is String) {
return switch (value) {
'stadium' => const StadiumBorder(),
'circle' => const CircleBorder(),
'none' => null,
'roundedRect' || _ => const RoundedRectangleBorder()
};
}
if (value is! Map) return null;
final shape = value['value'] as String?;
final borderColor =
(value['borderColor'] as String?).maybe(toColor) ?? Colors.transparent;
final borderWidth = NumUtil.toDouble(value['borderWidth']) ?? 1.0;
final borderStyle = (value['borderStyle'] == 'solid')
? BorderStyle.solid
: BorderStyle.none;
final side =
BorderSide(color: borderColor, width: borderWidth, style: borderStyle);
return switch (shape) {
'stadium' => StadiumBorder(side: side),
'circle' => CircleBorder(
eccentricity: NumUtil.toDouble(value['eccentricity']) ?? 0.0,
side: side),
'roundedRect' || _ => RoundedRectangleBorder(
borderRadius: borderRadius(value['borderRadius']), side: side)
};
}