Add semanticsLabel to SelectableText (#89369)
* add `semanticsLabel` to `SelectableText` * remove unused vars * Squashed commit of the following: commit3e687a9facAuthor: engine-flutter-autoroll <engine-flutter-autoroll@skia.org> Date: Tue Sep 14 17:42:05 2021 -0400 Roll Plugins from 4a98e239b131 to b85edebe7134 (2 revisions) (#90083) commitad936b4e4bAuthor: Christopher Fujino <christopherfujino@gmail.com> Date: Tue Sep 14 14:39:17 2021 -0700 [flutter_conductor] Support initial stable release version (#89775) commitff5dd54c6eAuthor: Ian Hickson <ian@hixie.ch> Date: Tue Sep 14 13:02:04 2021 -0700 Mention the ToS on our README (#89765) commit8587b609a6Author: Kate Lovett <katelovett@google.com> Date: Tue Sep 14 14:53:33 2021 -0500 Update local gold api (#90072) commit7d368dcf0cAuthor: Justin McCandless <jmccandless@google.com> Date: Tue Sep 14 12:39:19 2021 -0700 InteractiveViewer with a child of zero size (#90012) Asserts that the InteractiveViewer child can't have zero size. commit2b4ef184b7Author: Akira Aratani <developer.a.akira@gmail.com> Date: Wed Sep 15 03:30:50 2021 +0900 Fix document of the switch. (#89641) commita2cd16ba82Author: Christopher Fujino <christopherfujino@gmail.com> Date: Tue Sep 14 11:22:02 2021 -0700 use test logger, which does not allow colors (#90010) commit0f0613c0aeAuthor: Varun Sharma <varunsh@stepsecurity.io> Date: Tue Sep 14 11:17:03 2021 -0700 Add specific permissions to .github/workflows/lock.yaml (#89820) commit2866f79c89Author: Jason Simmons <jason-simmons@users.noreply.github.com> Date: Tue Sep 14 10:46:35 2021 -0700 Initialize all bindings before starting the text_editing_action_target test suite (#90067) Fixes https://github.com/flutter/flutter/issues/90057 commitb889915997Author: Michael Thomsen <mit@google.com> Date: Tue Sep 14 14:08:36 2021 +0200 Change min Dart SDK constraint to track actual version (#88743) commit3b7adb989fAuthor: godofredoc <54371434+godofredoc@users.noreply.github.com> Date: Mon Sep 13 21:32:04 2021 -0700 Lock only issues. (#90023) commit528f77dc99Author: Dan Field <dnfield@google.com> Date: Mon Sep 13 19:10:15 2021 -0700 Opacity fix (#90017) * Make sure Opacity widgets/layers do not drop the offset commit2470f63ebbAuthor: engine-flutter-autoroll <engine-flutter-autoroll@skia.org> Date: Mon Sep 13 22:07:02 2021 -0400 4a98e239b [flutter_plugin_tools] Make no unit tests fatal for iOS/macOS (flutter/plugins#4341) (#90016) commita01e4733dfAuthor: stuartmorgan <stuartmorgan@google.com> Date: Mon Sep 13 20:57:05 2021 -0400 Re-enable plugin analysis test (#89856) commitcdad35f2d8Author: Aneesh Rao <sidrao2006@gmail.com> Date: Tue Sep 14 05:17:04 2021 +0530 Fix path in example (#84707) commit576aab0833Author: Christopher Fujino <christopherfujino@gmail.com> Date: Mon Sep 13 15:47:03 2021 -0700 add analysis_options.yaml to dev/conductor (#90005) commitfad5e4cf89Author: Jason Simmons <jason-simmons@users.noreply.github.com> Date: Mon Sep 13 13:37:07 2021 -0700 Remove a redundant test case in the flutter_tools create_test (#89872) commit738430cad7Author: Darren Austin <darrenaustin@google.com> Date: Mon Sep 13 13:33:48 2021 -0700 Revert "Removed default page transitions for desktop and web platforms. (#82596)" (#89997) This reverts commit43e31977commit9db9256b38Author: Dan Field <dnfield@google.com> Date: Mon Sep 13 13:15:19 2021 -0700 Revert "Make sure Opacity widgets/layers do not drop the offset (#89264)" (#89999) This reverts commit0d0f7a4fb0. commit00f78cf263Author: keyonghan <54558023+keyonghan@users.noreply.github.com> Date: Mon Sep 13 13:04:01 2021 -0700 renew cirrus key (#89988) commit826da7f826Author: engine-flutter-autoroll <engine-flutter-autoroll@skia.org> Date: Mon Sep 13 15:52:03 2021 -0400 cfc8a20a1 renew cirrus key (flutter/plugins#4340) (#89996) commitcd112e551cAuthor: Anna Gringauze <annagrin@google.com> Date: Mon Sep 13 12:13:42 2021 -0700 Update all packages (#89797)
This commit is contained in:
@@ -198,6 +198,7 @@ class SelectableText extends StatefulWidget {
|
||||
this.selectionControls,
|
||||
this.onTap,
|
||||
this.scrollPhysics,
|
||||
this.semanticsLabel,
|
||||
this.textHeightBehavior,
|
||||
this.textWidthBasis,
|
||||
this.onSelectionChanged,
|
||||
@@ -255,6 +256,7 @@ class SelectableText extends StatefulWidget {
|
||||
this.selectionControls,
|
||||
this.onTap,
|
||||
this.scrollPhysics,
|
||||
this.semanticsLabel,
|
||||
this.textHeightBehavior,
|
||||
this.textWidthBasis,
|
||||
this.onSelectionChanged,
|
||||
@@ -409,6 +411,9 @@ class SelectableText extends StatefulWidget {
|
||||
/// {@macro flutter.widgets.editableText.scrollPhysics}
|
||||
final ScrollPhysics? scrollPhysics;
|
||||
|
||||
/// {@macro flutter.widgets.Text.semanticsLabel}
|
||||
final String? semanticsLabel;
|
||||
|
||||
/// {@macro flutter.dart:ui.textHeightBehavior}
|
||||
final TextHeightBehavior? textHeightBehavior;
|
||||
|
||||
@@ -425,6 +430,7 @@ class SelectableText extends StatefulWidget {
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<String>('data', data, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<String>('semanticsLabel', semanticsLabel, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<TextStyle>('style', style, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<bool>('autofocus', autofocus, defaultValue: false));
|
||||
@@ -697,6 +703,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
|
||||
);
|
||||
|
||||
return Semantics(
|
||||
label: widget.semanticsLabel,
|
||||
onLongPress: () {
|
||||
_effectiveFocusNode.requestFocus();
|
||||
},
|
||||
|
||||
@@ -494,6 +494,7 @@ class Text extends StatelessWidget {
|
||||
/// widget directly to entirely override the [DefaultTextStyle].
|
||||
final int? maxLines;
|
||||
|
||||
/// {@template flutter.widgets.Text.semanticsLabel}
|
||||
/// An alternative semantics label for this text.
|
||||
///
|
||||
/// If present, the semantics of this widget will contain this value instead
|
||||
@@ -506,6 +507,7 @@ class Text extends StatelessWidget {
|
||||
/// ```dart
|
||||
/// Text(r'$$', semanticsLabel: 'Double dollars')
|
||||
/// ```
|
||||
/// {@endtemplate}
|
||||
final String? semanticsLabel;
|
||||
|
||||
/// {@macro flutter.painting.textPainter.textWidthBasis}
|
||||
|
||||
@@ -2235,6 +2235,40 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('SelectableText semantics, with semanticsLabel', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final Key key = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
overlay(
|
||||
child: SelectableText(
|
||||
'Guten Tag',
|
||||
semanticsLabel: 'German greeting for good day',
|
||||
key: key,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(semantics, hasSemantics(TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics.rootChild(
|
||||
id: 1,
|
||||
textDirection: TextDirection.ltr,
|
||||
label: 'German greeting for good day',
|
||||
value: 'Guten Tag',
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.longPress,
|
||||
],
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isTextField,
|
||||
SemanticsFlag.isReadOnly,
|
||||
SemanticsFlag.isMultiline,
|
||||
],
|
||||
),
|
||||
],
|
||||
), ignoreTransform: true, ignoreRect: true));
|
||||
});
|
||||
|
||||
testWidgets('SelectableText semantics, enableInteractiveSelection = false', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
final Key key = UniqueKey();
|
||||
@@ -3850,6 +3884,7 @@ void main() {
|
||||
cursorRadius: Radius.zero,
|
||||
cursorColor: Color(0xff00ff00),
|
||||
scrollPhysics: ClampingScrollPhysics(),
|
||||
semanticsLabel: 'something else',
|
||||
enableInteractiveSelection: false,
|
||||
).debugFillProperties(builder);
|
||||
|
||||
@@ -3859,6 +3894,7 @@ void main() {
|
||||
|
||||
expect(description, <String>[
|
||||
'data: something',
|
||||
'semanticsLabel: something else',
|
||||
'style: TextStyle(inherit: true, color: Color(0xff00ff00))',
|
||||
'autofocus: true',
|
||||
'showCursor: true',
|
||||
|
||||
Reference in New Issue
Block a user