mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
borderRadius param updated in copyWith functions (#85822)
This commit is contained in:
parent
7a0b4669fc
commit
b1e1dd68ae
@ -82,7 +82,7 @@ class BeveledRectangleBorder extends OutlinedBorder {
|
||||
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
||||
/// replaced with the new values.
|
||||
@override
|
||||
BeveledRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
||||
BeveledRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||
return BeveledRectangleBorder(
|
||||
side: side ?? this.side,
|
||||
borderRadius: borderRadius ?? this.borderRadius,
|
||||
|
||||
@ -134,7 +134,7 @@ class ContinuousRectangleBorder extends OutlinedBorder {
|
||||
}
|
||||
|
||||
@override
|
||||
ContinuousRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
||||
ContinuousRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||
return ContinuousRectangleBorder(
|
||||
side: side ?? this.side,
|
||||
borderRadius: borderRadius ?? this.borderRadius,
|
||||
|
||||
@ -93,7 +93,7 @@ class RoundedRectangleBorder extends OutlinedBorder {
|
||||
/// Returns a copy of this RoundedRectangleBorder with the given fields
|
||||
/// replaced with the new values.
|
||||
@override
|
||||
RoundedRectangleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius }) {
|
||||
RoundedRectangleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius }) {
|
||||
return RoundedRectangleBorder(
|
||||
side: side ?? this.side,
|
||||
borderRadius: borderRadius ?? this.borderRadius,
|
||||
@ -272,7 +272,7 @@ class _RoundedRectangleToCircleBorder extends OutlinedBorder {
|
||||
}
|
||||
|
||||
@override
|
||||
_RoundedRectangleToCircleBorder copyWith({ BorderSide? side, BorderRadius? borderRadius, double? circleness }) {
|
||||
_RoundedRectangleToCircleBorder copyWith({ BorderSide? side, BorderRadiusGeometry? borderRadius, double? circleness }) {
|
||||
return _RoundedRectangleToCircleBorder(
|
||||
side: side ?? this.side,
|
||||
borderRadius: borderRadius ?? this.borderRadius,
|
||||
|
||||
@ -19,10 +19,16 @@ void main() {
|
||||
expect(const BeveledRectangleBorder().hashCode, const BeveledRectangleBorder().copyWith().hashCode);
|
||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||
expect(
|
||||
const BeveledRectangleBorder().copyWith(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', () {
|
||||
@ -74,4 +80,30 @@ void main() {
|
||||
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);
|
||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||
|
||||
expect(
|
||||
const ContinuousRectangleBorder().copyWith(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', () {
|
||||
@ -73,6 +80,31 @@ void main() {
|
||||
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 {
|
||||
await tester.pumpWidget(RepaintBoundary(
|
||||
child: Material(
|
||||
|
||||
@ -20,10 +20,17 @@ void main() {
|
||||
expect(const RoundedRectangleBorder().hashCode, const RoundedRectangleBorder().copyWith().hashCode);
|
||||
const BorderSide side = BorderSide(width: 10.0, color: Color(0xff123456));
|
||||
const BorderRadius radius = BorderRadius.all(Radius.circular(16.0));
|
||||
const BorderRadiusDirectional directionalRadius = BorderRadiusDirectional.all(Radius.circular(16.0));
|
||||
|
||||
expect(
|
||||
const RoundedRectangleBorder().copyWith(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', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user