Implementation
@override
ButtonStateProperty<Decoration> get decoration {
if (shape == ButtonShape.circle) {
return (context, states) {
var decoration = variance.decoration(context, states);
if (decoration is BoxDecoration) {
return BoxDecoration(
color: decoration.color,
image: decoration.image,
border: decoration.border,
borderRadius: null,
boxShadow: decoration.boxShadow,
gradient: decoration.gradient,
shape: BoxShape.circle,
backgroundBlendMode: decoration.backgroundBlendMode,
);
} else if (decoration is ShapeDecoration) {
return decoration.copyWith(
shape: shape == ButtonShape.circle ? const CircleBorder() : null,
);
} else {
throw Exception(
'Unsupported decoration type ${decoration.runtimeType}');
}
};
}
return variance.decoration;
}