@@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
4
4
import 'package:flutter_test/flutter_test.dart' ;
5
5
import 'package:flutter_test_runners/flutter_test_runners.dart' ;
6
6
import 'package:super_editor/src/infrastructure/platforms/ios/toolbar.dart' ;
7
+ import 'package:super_editor/super_editor_test.dart' ;
7
8
import 'package:super_editor/super_text_field.dart' ;
9
+ import 'package:super_text_layout/super_text_layout.dart' ;
8
10
9
11
import '../super_textfield_inspector.dart' ;
10
12
import '../super_textfield_robot.dart' ;
@@ -108,6 +110,41 @@ void main() {
108
110
// Ensure that the text field toolbar is visible.
109
111
expect (find.byType (IOSTextEditingFloatingToolbar ), findsOneWidget);
110
112
});
113
+
114
+ testWidgetsOnIos ('displays selection highlight when controller is not provided' , (tester) async {
115
+ // Pump a tree with a SuperIOSTextField without providing it a controller to make sure
116
+ // SuperIOSTextField does not rely on the provided controller to show the selection highlight.
117
+ //
118
+ // See https://github.com/superlistapp/super_editor/issues/2346 for details.
119
+ await tester.pumpWidget (
120
+ MaterialApp (
121
+ home: Scaffold (
122
+ body: ConstrainedBox (
123
+ constraints: const BoxConstraints (minWidth: 300 ),
124
+ child: const SuperIOSTextField (
125
+ padding: EdgeInsets .all (12 ),
126
+ caretStyle: CaretStyle (color: Colors .red),
127
+ selectionColor: defaultSelectionColor,
128
+ handlesColor: Colors .red,
129
+ textStyleBuilder: defaultTextFieldStyleBuilder,
130
+ ),
131
+ ),
132
+ ),
133
+ ),
134
+ );
135
+
136
+ // Place the caret at the beginning of the text.
137
+ await tester.placeCaretInSuperTextField (0 , find.byType (SuperIOSTextField ));
138
+
139
+ // Type some text.
140
+ await tester.typeImeText ('This is some text' );
141
+
142
+ // Double tap to select the word "some".
143
+ await tester.doubleTapAtSuperTextField (10 , find.byType (SuperIOSTextField ));
144
+
145
+ // Ensure the selection highlight is displayed.
146
+ expect (find.byType (TextLayoutSelectionHighlight ), findsOneWidget);
147
+ });
111
148
});
112
149
}
113
150
0 commit comments