@@ -70,6 +70,63 @@ void main() {
70
70
expect (tester.takeException (), isNull);
71
71
});
72
72
73
+ // Regression test for https://github.com/flutter/flutter/issues/111370
74
+ testWidgetsWithLeakTracking ('Handle is correctly transformed when the text is inside of a FittedBox ' ,(WidgetTester tester) async {
75
+ final Key textKey = UniqueKey ();
76
+ await tester.pumpWidget (
77
+ MaterialApp (
78
+ color: const Color (0xFF2196F3 ),
79
+ home: Scaffold (
80
+ body: SelectionArea (
81
+ child: SizedBox (
82
+ height: 100 ,
83
+ child: FittedBox (
84
+ fit: BoxFit .fill,
85
+ child: Text ('test' , key: textKey),
86
+ ),
87
+ ),
88
+ ),
89
+ ),
90
+ ),
91
+ );
92
+
93
+ final TestGesture longpress = await tester.startGesture (const Offset (10 , 10 ));
94
+ addTearDown (longpress.removePointer);
95
+ await tester.pump (const Duration (milliseconds: 500 ));
96
+ await longpress.up ();
97
+
98
+ // Text box is scaled by 5.
99
+ final RenderBox textBox = tester.firstRenderObject (find.byKey (textKey));
100
+ expect (textBox.size.height, 20.0 );
101
+ final Offset textPoint = textBox.localToGlobal (const Offset (0 , 20 ));
102
+ expect (textPoint, equals (const Offset (0 , 100 )));
103
+
104
+ // Find handles and verify their sizes.
105
+ expect (find.byType (Overlay ), findsOneWidget);
106
+ expect (find.descendant (of: find.byType (Overlay ),matching: find.byType (CustomPaint ),),findsNWidgets (2 ));
107
+ final Iterable <RenderBox > handles = tester.renderObjectList (find.descendant (
108
+ of: find.byType (Overlay ),
109
+ matching: find.byType (CustomPaint ),
110
+ ));
111
+
112
+ // The handle height is determined by the formula:
113
+ // textLineHeight + _kSelectionHandleRadius * 2 - _kSelectionHandleOverlap .
114
+ // The text line height will be the value of the fontSize.
115
+ // The constant _kSelectionHandleRadius has the value of 6.
116
+ // The constant _kSelectionHandleOverlap has the value of 1.5.
117
+ // The handle height before scaling is 20.0 + 6 * 2 - 1.5 = 30.5.
118
+
119
+ final double handleHeightBeforeScaling = handles.first.size.height;
120
+ expect (handleHeightBeforeScaling, 30.5 );
121
+
122
+ final Offset handleHeightAfterScaling = handles.first.localToGlobal (const Offset (0 , 30.5 )) - handles.first.localToGlobal (Offset .zero);
123
+
124
+ // The handle height after scaling is 30.5 * 5 = 152.5
125
+ expect (handleHeightAfterScaling, equals (const Offset (0.0 , 152.5 )));
126
+ },
127
+ skip: isBrowser, // [intended]
128
+ variant: const TargetPlatformVariant (< TargetPlatform > {TargetPlatform .iOS}),
129
+ );
73
130
74
131
testWidgetsWithLeakTracking ('builds the default context menu by default' , (WidgetTester tester) async {
75
132
final FocusNode focusNode = FocusNode ();
0 commit comments