@@ -883,4 +883,90 @@ void main() {
883883 ..restore (),
884884 );
885885 });
886+
887+ testWidgets ('ClipRRect supports BorderRadiusDirectional' , (WidgetTester tester) async {
888+ const Radius startRadius = Radius .circular (15.0 );
889+ const Radius endRadius = Radius .circular (30.0 );
890+
891+ Widget buildClipRRect (TextDirection textDirection) {
892+ return Directionality (
893+ textDirection: textDirection,
894+ child: const ClipRRect (
895+ borderRadius: BorderRadiusDirectional .horizontal (
896+ start: startRadius,
897+ end: endRadius,
898+ ),
899+ ),
900+ );
901+ }
902+
903+ for (final TextDirection textDirection in TextDirection .values) {
904+ await tester.pumpWidget (buildClipRRect (textDirection));
905+ final RenderClipRRect renderClip = tester.allRenderObjects.whereType <RenderClipRRect >().first;
906+ final bool isRtl = textDirection == TextDirection .rtl;
907+ expect (renderClip.borderRadius.resolve (textDirection).topLeft, isRtl ? endRadius : startRadius);
908+ expect (renderClip.borderRadius.resolve (textDirection).topRight, isRtl ? startRadius : endRadius);
909+ expect (renderClip.borderRadius.resolve (textDirection).bottomLeft, isRtl ? endRadius : startRadius);
910+ expect (renderClip.borderRadius.resolve (textDirection).bottomRight, isRtl ? startRadius : endRadius);
911+ }
912+ });
913+
914+ testWidgets ('ClipRRect is direction-aware' , (WidgetTester tester) async {
915+ const Radius startRadius = Radius .circular (15.0 );
916+ const Radius endRadius = Radius .circular (30.0 );
917+ TextDirection textDirection = TextDirection .ltr;
918+
919+ Widget buildClipRRect (TextDirection textDirection) {
920+ return Directionality (
921+ textDirection: textDirection,
922+ child: const ClipRRect (
923+ borderRadius: BorderRadiusDirectional .horizontal (
924+ start: startRadius,
925+ end: endRadius,
926+ ),
927+ ),
928+ );
929+ }
930+
931+ Widget buildStatefulClipRRect () {
932+ return StatefulBuilder (
933+ builder: (BuildContext context, StateSetter setState) {
934+ return Directionality (
935+ textDirection: textDirection,
936+ child: SizedBox (
937+ width: 100.0 ,
938+ height: 100.0 ,
939+ child: ClipRRect (
940+ borderRadius: const BorderRadiusDirectional .horizontal (
941+ start: startRadius,
942+ end: endRadius,
943+ ),
944+ child: GestureDetector (
945+ onTap: () {
946+ setState (() {
947+ textDirection = TextDirection .rtl;
948+ });
949+ },
950+ ),
951+ ),
952+ ),
953+ );
954+ },
955+ );
956+ }
957+
958+ for (final TextDirection textDirection in TextDirection .values) {
959+ await tester.pumpWidget (buildClipRRect (textDirection));
960+ final RenderClipRRect renderClip = tester.allRenderObjects.whereType <RenderClipRRect >().first;
961+ final bool isRtl = textDirection == TextDirection .rtl;
962+ expect (renderClip.textDirection, isRtl ? TextDirection .rtl : TextDirection .ltr);
963+ }
964+
965+ await tester.pumpWidget (buildStatefulClipRRect ());
966+ final RenderClipRRect renderClip = tester.allRenderObjects.whereType <RenderClipRRect >().first;
967+ expect (renderClip.textDirection, TextDirection .ltr);
968+ await tester.tapAt (Offset .zero);
969+ await tester.pump ();
970+ expect (renderClip.textDirection, TextDirection .rtl);
971+ });
886972}
0 commit comments