From 17f0d2e5deefb3685616f017382d6dadf670a3b1 Mon Sep 17 00:00:00 2001 From: nt4f04uNd Date: Fri, 20 Aug 2021 19:42:05 +0300 Subject: [PATCH] init (#88391) --- .../lib/src/painting/box_decoration.dart | 2 +- .../test/widgets/box_decoration_test.dart | 54 ++++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index ea2ad4fde8..757bf60661 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -485,7 +485,7 @@ class _BoxDecorationPainter extends BoxPainter { canvas, rect, shape: _decoration.shape, - borderRadius: _decoration.borderRadius as BorderRadius?, + borderRadius: _decoration.borderRadius?.resolve(textDirection), textDirection: configuration.textDirection, ); } diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index df1f85fad2..9d68f86ac5 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -391,7 +391,7 @@ Future main() async { itemsTapped = []; return Align( alignment: Alignment.topLeft, - child:GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.deferToChild, child: Container( key: key, @@ -424,16 +424,16 @@ Future main() async { const Offset fartherBorderRadiusPoint = Offset(borderDiagonalOffset,borderDiagonalOffset); await tester.tapAt(topLeft); - expect(itemsTapped, isEmpty,reason: 'top left tapped'); + expect(itemsTapped, isEmpty, reason: 'top left tapped'); await tester.tapAt(borderTopTangent); - expect(itemsTapped, isEmpty,reason: 'border top tapped'); + expect(itemsTapped, isEmpty, reason: 'border top tapped'); await tester.tapAt(borderLeftTangent); - expect(itemsTapped, isEmpty,reason: 'border left tapped'); + expect(itemsTapped, isEmpty, reason: 'border left tapped'); await tester.tapAt(fartherBorderRadiusPoint); - expect(itemsTapped, isEmpty,reason: 'border center tapped'); + expect(itemsTapped, isEmpty, reason: 'border center tapped'); await tester.tap(find.byKey(key)); expect(itemsTapped, [1]); @@ -451,7 +451,7 @@ Future main() async { itemsTapped = []; return Align( alignment: Alignment.topLeft, - child:GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.deferToChild, child: Container( key: key, @@ -476,13 +476,13 @@ Future main() async { const Offset fartherBorderRadiusPoint = Offset(borderDiagonalOffset+1,borderDiagonalOffset+1); await tester.tapAt(borderTopTangent); - expect(itemsTapped, [1],reason: 'border Top not tapped'); + expect(itemsTapped, [1], reason: 'border Top not tapped'); await tester.tapAt(borderLeftTangent); - expect(itemsTapped, [1,1],reason: 'border Left not tapped'); + expect(itemsTapped, [1,1], reason: 'border Left not tapped'); await tester.tapAt(fartherBorderRadiusPoint); - expect(itemsTapped, [1,1,1],reason: 'border center not tapped'); + expect(itemsTapped, [1,1,1], reason: 'border center not tapped'); await tester.tap(find.byKey(key)); expect(itemsTapped, [1,1,1,1]); @@ -499,7 +499,7 @@ Future main() async { itemsTapped = []; return Align( alignment: Alignment.topLeft, - child:GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.deferToChild, child: Container( key: key, @@ -532,27 +532,45 @@ Future main() async { const Offset topLeftInside = Offset(radius, radius); await tester.tapAt(topRightInside); - expect(itemsTapped, [1,1],reason: 'top right not tapped'); + expect(itemsTapped, [1,1], reason: 'top right not tapped'); await tester.tapAt(topRightOutside); - expect(itemsTapped, [1,1],reason: 'top right tapped'); + expect(itemsTapped, [1,1], reason: 'top right tapped'); await tester.tapAt(bottomRightInside); - expect(itemsTapped, [1,1,1],reason: 'bottom right not tapped'); + expect(itemsTapped, [1,1,1], reason: 'bottom right not tapped'); await tester.tapAt(bottomRightOutside); - expect(itemsTapped, [1,1,1],reason: 'bottom right tapped'); + expect(itemsTapped, [1,1,1], reason: 'bottom right tapped'); await tester.tapAt(bottomLeftInside); - expect(itemsTapped, [1,1,1,1],reason: 'bottom left not tapped'); + expect(itemsTapped, [1,1,1,1], reason: 'bottom left not tapped'); await tester.tapAt(bottomLeftOutside); - expect(itemsTapped, [1,1,1,1],reason: 'bottom left tapped'); + expect(itemsTapped, [1,1,1,1], reason: 'bottom left tapped'); await tester.tapAt(topLeftInside); - expect(itemsTapped, [1,1,1,1,1],reason: 'top left not tapped'); + expect(itemsTapped, [1,1,1,1,1], reason: 'top left not tapped'); await tester.tapAt(topLeftOutside); - expect(itemsTapped, [1,1,1,1,1],reason: 'top left tapped'); + expect(itemsTapped, [1,1,1,1,1], reason: 'top left tapped'); + }); + + testWidgets("BoxDecoration doesn't crash with BorderRadiusDirectional", (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/88039 + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: Container( + decoration: BoxDecoration( + border: Border.all(), + borderRadius: const BorderRadiusDirectional.all( + Radius.circular(1.0), + ), + ), + ), + ), + ); }); }