applyToBorderRadius method
BorderRadiusGeometry
applyToBorderRadius(
- BorderRadiusGeometry borderRadius,
- TextDirection textDirection
Applies corner multipliers to a border radius.
Multiplies each corner's radius by the corresponding corner value, properly handling text direction for start/end mapping to left/right.
Parameters:
borderRadius: The base border radius to modifytextDirection: Text direction for resolving start/end to left/right
Returns a new BorderRadiusGeometry with modified corner radii.
Implementation
BorderRadiusGeometry applyToBorderRadius(
BorderRadiusGeometry borderRadius, TextDirection textDirection) {
final topLeftValue =
textDirection == TextDirection.ltr ? topStartValue : topEndValue;
final topRightValue =
textDirection == TextDirection.ltr ? topEndValue : topStartValue;
final bottomLeftValue =
textDirection == TextDirection.ltr ? bottomStartValue : bottomEndValue;
final bottomRightValue =
textDirection == TextDirection.ltr ? bottomEndValue : bottomStartValue;
final resolvedBorderRadius = borderRadius.resolve(textDirection);
return BorderRadius.only(
topLeft: Radius.elliptical(
resolvedBorderRadius.topLeft.x * topLeftValue,
resolvedBorderRadius.topLeft.y * topLeftValue,
),
topRight: Radius.elliptical(
resolvedBorderRadius.topRight.x * topRightValue,
resolvedBorderRadius.topRight.y * topRightValue,
),
bottomLeft: Radius.elliptical(
resolvedBorderRadius.bottomLeft.x * bottomLeftValue,
resolvedBorderRadius.bottomLeft.y * bottomLeftValue,
),
bottomRight: Radius.elliptical(
resolvedBorderRadius.bottomRight.x * bottomRightValue,
resolvedBorderRadius.bottomRight.y * bottomRightValue,
),
);
}