withBorder method
Creates a copy with custom borders for different states.
Modifies the decoration to apply state-specific borders. Only works with BoxDecoration; other decoration types are returned unchanged.
Parameters:
border: Border for normal statehoverBorder: Border when hoveredfocusBorder: Border when focuseddisabledBorder: Border when disabled
Example:
final style = ButtonVariance.outline.withBorder(
border: Border.all(color: Colors.blue),
hoverBorder: Border.all(color: Colors.blue.shade700, width: 2),
);
Implementation
AbstractButtonStyle withBorder(
{Border? border,
Border? hoverBorder,
Border? focusBorder,
Border? disabledBorder}) {
return copyWith(
decoration: (context, states, decoration) {
if (decoration is BoxDecoration) {
return decoration.copyWith(
border: states.disabled
? disabledBorder ?? decoration.border
: states.hovered
? hoverBorder ?? decoration.border
: states.focused
? focusBorder ?? decoration.border
: border,
);
}
return decoration;
},
);
}