borderRadius param updated in copyWith functions (#85822)
This commit is contained in:
@@ -82,7 +82,7 @@ class BeveledRectangleBorder extends OutlinedBorder {
|
|||||||
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
||||||
/// replaced with the new values.
|
/// replaced with the new values.
|
||||||
@override
|
@override
|
||||||
BeveledRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
BeveledRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||||
return BeveledRectangleBorder(
|
return BeveledRectangleBorder(
|
||||||
side: side ?? this.side,
|
side: side ?? this.side,
|
||||||
borderRadius: borderRadius ?? this.borderRadius,
|
borderRadius: borderRadius ?? this.borderRadius,
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class ContinuousRectangleBorder extends OutlinedBorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ContinuousRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
ContinuousRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||||
return ContinuousRectangleBorder(
|
return ContinuousRectangleBorder(
|
||||||
side: side ?? this.side,
|
side: side ?? this.side,
|
||||||
borderRadius: borderRadius ?? this.borderRadius,
|
borderRadius: borderRadius ?? this.borderRadius,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class RoundedRectangleBorder extends OutlinedBorder {
|
|||||||
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
||||||
/// replaced with the new values.
|
/// replaced with the new values.
|
||||||
@override
|
@override
|
||||||
RoundedRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
RoundedRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||||
return RoundedRectangleBorder(
|
return RoundedRectangleBorder(
|
||||||
side: side ?? this.side,
|
side: side ?? this.side,
|
||||||
borderRadius: borderRadius ?? this.borderRadius,
|
borderRadius: borderRadius ?? this.borderRadius,
|
||||||
@@ -272,7 +272,7 @@ class _RoundedRectangleToCircleBorder extends OutlinedBorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_RoundedRectangleToCircleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius, double? circleness }) {
|
_RoundedRectangleToCircleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius, double? circleness }) {
|
||||||
return _RoundedRectangleToCircleBorder(
|
return _RoundedRectangleToCircleBorder(
|
||||||
side: side ?? this.side,
|
side: side ?? this.side,
|
||||||
borderRadius: borderRadius ?? this.borderRadius,
|
borderRadius: borderRadius ?? this.borderRadius,
|
||||||
|
|||||||
@@ -19,10 +19,16 @@ void main() {
|
|||||||
expect(const BeveledRectangleBorder().hashCode, const BeveledRectangleBorder().copyWith().hashCode);
|
expect(const BeveledRectangleBorder().hashCode, const BeveledRectangleBorder().copyWith().hashCode);
|
||||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||||
|
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||||
expect(
|
expect(
|
||||||
const BeveledRectangleBorder().copyWith(side: side, borderRadius: radius),
|
const BeveledRectangleBorder().copyWith(side: side, borderRadius: radius),
|
||||||
const BeveledRectangleBorder(side: side, borderRadius: radius),
|
const BeveledRectangleBorder(side: side, borderRadius: radius),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
const BeveledRectangleBorder().copyWith(side: side, borderRadius: directionalRadius),
|
||||||
|
const BeveledRectangleBorder(side: side, borderRadius: directionalRadius),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('BeveledRectangleBorder scale and lerp', () {
|
test('BeveledRectangleBorder scale and lerp', () {
|
||||||
@@ -74,4 +80,30 @@ void main() {
|
|||||||
expect(border.getInnerPath(rect), looksLikeRect);
|
expect(border.getInnerPath(rect), looksLikeRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('BeveledRectangleBorder non-zero BorderRadiusDirectional', () {
|
||||||
|
const Rect rect = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0);
|
||||||
|
final Matcher looksLikeRectLtr = isPathThat(
|
||||||
|
includes: const <Offset>[Offset(15.0, 25.0), Offset(20.0, 30.0)],
|
||||||
|
excludes: const <Offset>[Offset(10.0, 20.0), Offset(10.0, 40.0)],
|
||||||
|
);
|
||||||
|
const BeveledRectangleBorder border = BeveledRectangleBorder(
|
||||||
|
borderRadius: BorderRadiusDirectional.only(
|
||||||
|
topStart: Radius.circular(5.0),
|
||||||
|
bottomStart: Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test ltr situation
|
||||||
|
expect(border.getOuterPath(rect,textDirection: TextDirection.ltr), looksLikeRectLtr);
|
||||||
|
expect(border.getInnerPath(rect,textDirection: TextDirection.ltr), looksLikeRectLtr);
|
||||||
|
|
||||||
|
final Matcher looksLikeRectRtl = isPathThat(
|
||||||
|
includes: const <Offset>[Offset(25.0, 35.0), Offset(25.0, 25.0)],
|
||||||
|
excludes: const <Offset>[Offset(30.0, 20.0), Offset(30.0, 40.0)],
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test Rtl situation
|
||||||
|
expect(border.getOuterPath(rect,textDirection: TextDirection.rtl), looksLikeRectRtl);
|
||||||
|
expect(border.getInnerPath(rect,textDirection: TextDirection.rtl), looksLikeRectRtl);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,17 @@ void main() {
|
|||||||
expect(const ContinuousRectangleBorder().hashCode, const ContinuousRectangleBorder().copyWith().hashCode);
|
expect(const ContinuousRectangleBorder().hashCode, const ContinuousRectangleBorder().copyWith().hashCode);
|
||||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||||
|
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
const ContinuousRectangleBorder().copyWith(side: side, borderRadius: radius),
|
const ContinuousRectangleBorder().copyWith(side: side, borderRadius: radius),
|
||||||
const ContinuousRectangleBorder(side: side, borderRadius: radius),
|
const ContinuousRectangleBorder(side: side, borderRadius: radius),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
const ContinuousRectangleBorder().copyWith(side: side, borderRadius: directionalRadius),
|
||||||
|
const ContinuousRectangleBorder(side: side, borderRadius: directionalRadius),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ContinuousRectangleBorder scale and lerp', () {
|
test('ContinuousRectangleBorder scale and lerp', () {
|
||||||
@@ -73,6 +80,31 @@ void main() {
|
|||||||
expect(border.getInnerPath(rect), looksLikeRect);
|
expect(border.getInnerPath(rect), looksLikeRect);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('ContinuousRectangleBorder non-zero BorderRadiusDirectional', () {
|
||||||
|
const Rect rect = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0);
|
||||||
|
final Matcher looksLikeRectLtr = isPathThat(
|
||||||
|
includes: const <Offset>[Offset(15.0, 25.0), Offset(20.0, 30.0)],
|
||||||
|
excludes: const <Offset>[Offset(10.0, 20.0), Offset(10.0, 40.0)],
|
||||||
|
);
|
||||||
|
const ContinuousRectangleBorder border = ContinuousRectangleBorder(
|
||||||
|
borderRadius: BorderRadiusDirectional.only(
|
||||||
|
topStart: Radius.circular(5.0),
|
||||||
|
bottomStart: Radius.circular(5.0),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(border.getOuterPath(rect,textDirection: TextDirection.ltr), looksLikeRectLtr);
|
||||||
|
expect(border.getInnerPath(rect,textDirection: TextDirection.ltr), looksLikeRectLtr);
|
||||||
|
|
||||||
|
final Matcher looksLikeRectRtl = isPathThat(
|
||||||
|
includes: const <Offset>[Offset(25.0, 35.0), Offset(25.0, 25.0)],
|
||||||
|
excludes: const <Offset>[Offset(30.0, 20.0), Offset(30.0, 40.0)],
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(border.getOuterPath(rect,textDirection: TextDirection.rtl), looksLikeRectRtl);
|
||||||
|
expect(border.getInnerPath(rect,textDirection: TextDirection.rtl), looksLikeRectRtl);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Golden test even radii', (WidgetTester tester) async {
|
testWidgets('Golden test even radii', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(RepaintBoundary(
|
await tester.pumpWidget(RepaintBoundary(
|
||||||
child: Material(
|
child: Material(
|
||||||
|
|||||||
@@ -20,10 +20,17 @@ void main() {
|
|||||||
expect(const RoundedRectangleBorder().hashCode, const RoundedRectangleBorder().copyWith().hashCode);
|
expect(const RoundedRectangleBorder().hashCode, const RoundedRectangleBorder().copyWith().hashCode);
|
||||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||||
|
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
const RoundedRectangleBorder().copyWith(side: side, borderRadius: radius),
|
const RoundedRectangleBorder().copyWith(side: side, borderRadius: radius),
|
||||||
const RoundedRectangleBorder(side: side, borderRadius: radius),
|
const RoundedRectangleBorder(side: side, borderRadius: radius),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
const RoundedRectangleBorder().copyWith(side: side, borderRadius: directionalRadius),
|
||||||
|
const RoundedRectangleBorder(side: side, borderRadius: directionalRadius),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('RoundedRectangleBorder', () {
|
test('RoundedRectangleBorder', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user