From 03f107ad31d6b91d01f0e892ef02eb6bf1258982 Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Sat, 12 Jul 2025 00:04:49 +0200 Subject: [PATCH 1/5] Update text.dart --- packages/flutter/lib/src/widgets/text.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index fe4c37f69d96b..031a9820bf920 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -735,6 +735,7 @@ class Text extends StatelessWidget { text: TextSpan( style: effectiveTextStyle, text: data, + locale: locale, children: textSpan != null ? [textSpan!] : null, ), ), @@ -762,6 +763,7 @@ class Text extends StatelessWidget { text: TextSpan( style: effectiveTextStyle, text: data, + locale: locale, children: textSpan != null ? [textSpan!] : null, ), ); From 3c5672c122d0eaee6cba3ecbaabb47924ba1e1f0 Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Sat, 12 Jul 2025 00:09:49 +0200 Subject: [PATCH 2/5] wip --- .../test/widgets/text_semantics_test.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/flutter/test/widgets/text_semantics_test.dart b/packages/flutter/test/widgets/text_semantics_test.dart index 3232d69fd5c00..6bcc6ea41d3d3 100644 --- a/packages/flutter/test/widgets/text_semantics_test.dart +++ b/packages/flutter/test/widgets/text_semantics_test.dart @@ -173,4 +173,24 @@ void main() { expect(labelToNodeId['has been created.'], ''); expect(labelToNodeId.length, 3); }); + + testWidgets('GIVEN a Text widget with a locale ' + 'WHEN semantics are built ' + 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { + const Locale locale = Locale('de', 'DE'); + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: Text('Flutter 2050', locale: locale), + ), + ); + + final SemanticsNode node = tester.getSemantics(find.text('Flutter 2025')); + final LocaleStringAttribute localeStringAttribute = + node.attributedLabel.attributes[0] as LocaleStringAttribute; + + expect(node.label, 'Flutter 2050'); + expect(localeStringAttribute.locale.toLanguageTag(), 'de-DE'); + }); } From b735c2c050ac409d36007411bd961041cb683a17 Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Sat, 12 Jul 2025 00:39:34 +0200 Subject: [PATCH 3/5] wip --- .../test/widgets/text_semantics_test.dart | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/flutter/test/widgets/text_semantics_test.dart b/packages/flutter/test/widgets/text_semantics_test.dart index 6bcc6ea41d3d3..32c368aa608f0 100644 --- a/packages/flutter/test/widgets/text_semantics_test.dart +++ b/packages/flutter/test/widgets/text_semantics_test.dart @@ -173,7 +173,7 @@ void main() { expect(labelToNodeId['has been created.'], ''); expect(labelToNodeId.length, 3); }); - + testWidgets('GIVEN a Text widget with a locale ' 'WHEN semantics are built ' 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { @@ -193,4 +193,32 @@ void main() { expect(node.label, 'Flutter 2050'); expect(localeStringAttribute.locale.toLanguageTag(), 'de-DE'); }); + + testWidgets('GIVEN a Text with a locale is within a SelectionContainer ' + 'WHEN semantics are built ' + 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { + const Locale locale = Locale('de', 'DE'); + const String text = 'Flutter 2050'; + await tester.pumpWidget( + const MaterialApp(home: SelectionArea(child: Text(text, locale: locale))), + ); + await tester.pumpAndSettle(); + + final SemanticsNode root = tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!; + final List queue = [root]; + SemanticsNode? targetNode; + while (queue.isNotEmpty) { + final SemanticsNode node = queue.removeAt(0); + if (node.label == text) { + targetNode = node; + break; + } + queue.addAll(node.debugListChildrenInOrder(DebugSemanticsDumpOrder.traversalOrder)); + } + final LocaleStringAttribute localeStringAttribute = + targetNode!.attributedLabel.attributes[0] as LocaleStringAttribute; + + expect(targetNode.label, text); + expect(localeStringAttribute.locale.toLanguageTag(), 'de-DE'); + }); } From 950215971548f164463ea59ad5ca532ba6c25c96 Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Thu, 17 Jul 2025 20:40:08 +0200 Subject: [PATCH 4/5] fix tests --- packages/flutter/test/widgets/text_semantics_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter/test/widgets/text_semantics_test.dart b/packages/flutter/test/widgets/text_semantics_test.dart index 32c368aa608f0..a1eeb2daaa5ac 100644 --- a/packages/flutter/test/widgets/text_semantics_test.dart +++ b/packages/flutter/test/widgets/text_semantics_test.dart @@ -186,7 +186,7 @@ void main() { ), ); - final SemanticsNode node = tester.getSemantics(find.text('Flutter 2025')); + final SemanticsNode node = tester.getSemantics(find.byType(Directionality)); final LocaleStringAttribute localeStringAttribute = node.attributedLabel.attributes[0] as LocaleStringAttribute; From bc4bda9c89146d84fd06e733d5d4ca33ebc7a928 Mon Sep 17 00:00:00 2001 From: Pedro Massango Date: Thu, 17 Jul 2025 21:34:22 +0200 Subject: [PATCH 5/5] wip --- .../test/widgets/text_semantics_test.dart | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/flutter/test/widgets/text_semantics_test.dart b/packages/flutter/test/widgets/text_semantics_test.dart index a1eeb2daaa5ac..967c994002f38 100644 --- a/packages/flutter/test/widgets/text_semantics_test.dart +++ b/packages/flutter/test/widgets/text_semantics_test.dart @@ -173,12 +173,12 @@ void main() { expect(labelToNodeId['has been created.'], ''); expect(labelToNodeId.length, 3); }); - + testWidgets('GIVEN a Text widget with a locale ' - 'WHEN semantics are built ' - 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { + 'WHEN semantics are built ' + 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { const Locale locale = Locale('de', 'DE'); - + await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, @@ -193,14 +193,16 @@ void main() { expect(node.label, 'Flutter 2050'); expect(localeStringAttribute.locale.toLanguageTag(), 'de-DE'); }); - + testWidgets('GIVEN a Text with a locale is within a SelectionContainer ' - 'WHEN semantics are built ' - 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { + 'WHEN semantics are built ' + 'THEN the SemanticsNode contains the correct language tag', (WidgetTester tester) async { const Locale locale = Locale('de', 'DE'); const String text = 'Flutter 2050'; await tester.pumpWidget( - const MaterialApp(home: SelectionArea(child: Text(text, locale: locale))), + const MaterialApp( + home: SelectionArea(child: Text(text, locale: locale)), + ), ); await tester.pumpAndSettle(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy