@@ -6586,7 +6586,39 @@ void main() {
6586
6586
expect (tester.getBottomLeft (find.byKey (keyB)).dy, rowBottomY);
6587
6587
});
6588
6588
6589
- testWidgets ('TextField semantics include label when unfocused and label/hint when focused' , (WidgetTester tester) async {
6589
+ testWidgets ('TextField semantics include label when unfocused and label/hint when focused if input is empty' , (WidgetTester tester) async {
6590
+ final SemanticsTester semantics = SemanticsTester (tester);
6591
+ final TextEditingController controller = TextEditingController (text: '' );
6592
+ final Key key = UniqueKey ();
6593
+
6594
+ await tester.pumpWidget (
6595
+ overlay (
6596
+ child: TextField (
6597
+ key: key,
6598
+ controller: controller,
6599
+ decoration: const InputDecoration (
6600
+ hintText: 'hint' ,
6601
+ labelText: 'label' ,
6602
+ ),
6603
+ ),
6604
+ ),
6605
+ );
6606
+
6607
+ final SemanticsNode node = tester.getSemantics (find.byKey (key));
6608
+
6609
+ expect (node.label, 'label' );
6610
+ expect (node.value, '' );
6611
+
6612
+ // Focus text field.
6613
+ await tester.tap (find.byKey (key));
6614
+ await tester.pump ();
6615
+
6616
+ expect (node.label, 'label\n hint' );
6617
+ expect (node.value, '' );
6618
+ semantics.dispose ();
6619
+ });
6620
+
6621
+ testWidgets ('TextField semantics alway include label and not hint when input value is not empty' , (WidgetTester tester) async {
6590
6622
final SemanticsTester semantics = SemanticsTester (tester);
6591
6623
final TextEditingController controller = TextEditingController (text: 'value' );
6592
6624
final Key key = UniqueKey ();
@@ -6613,7 +6645,7 @@ void main() {
6613
6645
await tester.tap (find.byKey (key));
6614
6646
await tester.pump ();
6615
6647
6616
- expect (node.label, 'label\n hint ' );
6648
+ expect (node.label, 'label' );
6617
6649
expect (node.value, 'value' );
6618
6650
semantics.dispose ();
6619
6651
});
0 commit comments