@@ -16,7 +16,7 @@ void main() {
1616 // to ease the check on [Rect] later.
1717 alignment: Alignment .topLeft,
1818 child: SizedBox (width: 20 , height: 20 ,
19- child: InsetShadowBox (top: 7 , bottom: 3 ,
19+ child: InsetShadowBox (top: 7 , bottom: 3 , start : 5 , end : 6 ,
2020 color: Colors .red,
2121 child: SizedBox .shrink ())))));
2222
@@ -42,7 +42,7 @@ void main() {
4242 };
4343 }
4444
45- testWidgets ('render shadow correctly' , (tester) async {
45+ testWidgets ('render shadow correctly: top/bottom ' , (tester) async {
4646 await tester.pumpWidget (const Directionality (
4747 textDirection: TextDirection .ltr,
4848 child: Center (
@@ -61,4 +61,33 @@ void main() {
6161 ..something (paintGradient (rect: const Rect .fromLTRB (0 , 100 - 7 , 100 , 100 )))
6262 ) as Matcher );
6363 });
64+
65+ final textDirectionVariant =
66+ ValueVariant <TextDirection >({TextDirection .ltr, TextDirection .rtl});
67+
68+ testWidgets ('render shadow correctly: start/end' , (tester) async {
69+ final textDirection = textDirectionVariant.currentValue! ;
70+ await tester.pumpWidget (Directionality (
71+ textDirection: textDirection,
72+ child: Center (
73+ // This would be forced to fill up the screen
74+ // if not wrapped in a widget like [Center].
75+ child: SizedBox (width: 100 , height: 100 ,
76+ child: InsetShadowBox (start: 3 , end: 7 ,
77+ color: Colors .red,
78+ child: SizedBox (width: 30 , height: 30 ))))));
79+
80+ final box = tester.renderObject (find.byType (InsetShadowBox ));
81+ check (box).legacyMatcher (
82+ // The coordinate system of these [Rect]'s is relative to the parent
83+ // of the [Gradient] from [InsetShadowBox], not the entire [FlutterView].
84+ switch (textDirection) {
85+ TextDirection .ltr => paints
86+ ..something (paintGradient (rect: Rect .fromLTRB (0 , 0 , 0 + 3 , 100 )))
87+ ..something (paintGradient (rect: Rect .fromLTRB (100 - 7 , 0 , 100 , 100 ))),
88+ TextDirection .rtl => paints
89+ ..something (paintGradient (rect: Rect .fromLTRB (100 - 3 , 0 , 100 , 100 )))
90+ ..something (paintGradient (rect: Rect .fromLTRB (0 , 0 , 0 + 7 , 100 ))),
91+ } as Matcher );
92+ }, variant: textDirectionVariant);
6493}
0 commit comments