@@ -316,6 +316,7 @@ class SemanticsData with Diagnosticable {
316316 required this .attributedIncreasedValue,
317317 required this .attributedDecreasedValue,
318318 required this .attributedHint,
319+ required this .tooltip,
319320 required this .textDirection,
320321 required this .rect,
321322 required this .elevation,
@@ -339,6 +340,7 @@ class SemanticsData with Diagnosticable {
339340 assert (attributedDecreasedValue != null ),
340341 assert (attributedIncreasedValue != null ),
341342 assert (attributedHint != null ),
343+ assert (tooltip == '' || textDirection != null , 'A SemanticsData object with tooltip "$tooltip " had a null textDirection.' ),
342344 assert (attributedLabel.string == '' || textDirection != null , 'A SemanticsData object with label "${attributedLabel .string }" had a null textDirection.' ),
343345 assert (attributedValue.string == '' || textDirection != null , 'A SemanticsData object with value "${attributedValue .string }" had a null textDirection.' ),
344346 assert (attributedDecreasedValue.string == '' || textDirection != null , 'A SemanticsData object with decreasedValue "${attributedDecreasedValue .string }" had a null textDirection.' ),
@@ -429,6 +431,11 @@ class SemanticsData with Diagnosticable {
429431 /// See also [hint] , which exposes just the raw text.
430432 final AttributedString attributedHint;
431433
434+ /// A textual description of the widget's tooltip.
435+ ///
436+ /// The reading direction is given by [textDirection] .
437+ final String tooltip;
438+
432439 /// The reading direction for the text in [label] , [value] ,
433440 /// [increasedValue] , [decreasedValue] , and [hint] .
434441 final TextDirection ? textDirection;
@@ -587,6 +594,7 @@ class SemanticsData with Diagnosticable {
587594 properties.add (AttributedStringProperty ('increasedValue' , attributedIncreasedValue));
588595 properties.add (AttributedStringProperty ('decreasedValue' , attributedDecreasedValue));
589596 properties.add (AttributedStringProperty ('hint' , attributedHint));
597+ properties.add (StringProperty ('tooltip' , tooltip, defaultValue: '' ));
590598 properties.add (EnumProperty <TextDirection >('textDirection' , textDirection, defaultValue: null ));
591599 if (textSelection? .isValid ?? false )
592600 properties.add (MessageProperty ('textSelection' , '[${textSelection !.start }, ${textSelection !.end }]' ));
@@ -610,6 +618,7 @@ class SemanticsData with Diagnosticable {
610618 && other.attributedIncreasedValue == attributedIncreasedValue
611619 && other.attributedDecreasedValue == attributedDecreasedValue
612620 && other.attributedHint == attributedHint
621+ && other.tooltip == tooltip
613622 && other.textDirection == textDirection
614623 && other.rect == rect
615624 && setEquals (other.tags, tags)
@@ -637,6 +646,7 @@ class SemanticsData with Diagnosticable {
637646 attributedIncreasedValue,
638647 attributedDecreasedValue,
639648 attributedHint,
649+ tooltip,
640650 textDirection,
641651 rect,
642652 tags,
@@ -648,8 +658,8 @@ class SemanticsData with Diagnosticable {
648658 scrollExtentMin,
649659 platformViewId,
650660 maxValueLength,
651- currentValueLength,
652661 Object .hash (
662+ currentValueLength,
653663 transform,
654664 elevation,
655665 thickness,
@@ -785,6 +795,7 @@ class SemanticsProperties extends DiagnosticableTree {
785795 this .decreasedValue,
786796 this .attributedDecreasedValue,
787797 this .hint,
798+ this .tooltip,
788799 this .attributedHint,
789800 this .hintOverrides,
790801 this .textDirection,
@@ -1178,6 +1189,16 @@ class SemanticsProperties extends DiagnosticableTree {
11781189 /// * [hint] for a plain string version of this property.
11791190 final AttributedString ? attributedHint;
11801191
1192+ /// Provides a textual description of the widget's tooltip.
1193+ ///
1194+ /// In Android, this property sets the `AccessibilityNodeInfo.setTooltipText` .
1195+ /// In iOS, this property is appended to the end of the
1196+ /// `UIAccessibilityElement.accessibilityLabel` .
1197+ ///
1198+ /// If a [tooltip] is provided, there must either by an ambient
1199+ /// [Directionality] or an explicit [textDirection] should be provided.
1200+ final String ? tooltip;
1201+
11811202 /// Provides hint values which override the default hints on supported
11821203 /// platforms.
11831204 ///
@@ -1469,6 +1490,7 @@ class SemanticsProperties extends DiagnosticableTree {
14691490 properties.add (AttributedStringProperty ('attributedDecreasedValue' , attributedDecreasedValue, defaultValue: null ));
14701491 properties.add (StringProperty ('hint' , hint, defaultValue: null ));
14711492 properties.add (AttributedStringProperty ('attributedHint' , attributedHint, defaultValue: null ));
1493+ properties.add (StringProperty ('tooltip' , tooltip));
14721494 properties.add (EnumProperty <TextDirection >('textDirection' , textDirection, defaultValue: null ));
14731495 properties.add (DiagnosticsProperty <SemanticsSortKey >('sortKey' , sortKey, defaultValue: null ));
14741496 properties.add (DiagnosticsProperty <SemanticsHintOverrides >('hintOverrides' , hintOverrides, defaultValue: null ));
@@ -1898,6 +1920,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
18981920 || _attributedValue != config.attributedValue
18991921 || _attributedIncreasedValue != config.attributedIncreasedValue
19001922 || _attributedDecreasedValue != config.attributedDecreasedValue
1923+ || _tooltip != config.tooltip
19011924 || _flags != config._flags
19021925 || _textDirection != config.textDirection
19031926 || _sortKey != config._sortKey
@@ -2027,6 +2050,12 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
20272050 AttributedString get attributedHint => _attributedHint;
20282051 AttributedString _attributedHint = _kEmptyConfig.attributedHint;
20292052
2053+ /// A textual description of the widget's tooltip.
2054+ ///
2055+ /// The reading direction is given by [textDirection] .
2056+ String get tooltip => _tooltip;
2057+ String _tooltip = _kEmptyConfig.tooltip;
2058+
20302059 /// The elevation along the z-axis at which the [rect] of this [SemanticsNode]
20312060 /// is located above its parent.
20322061 ///
@@ -2235,6 +2264,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
22352264 _attributedIncreasedValue = config.attributedIncreasedValue;
22362265 _attributedDecreasedValue = config.attributedDecreasedValue;
22372266 _attributedHint = config.attributedHint;
2267+ _tooltip = config.tooltip;
22382268 _hintOverrides = config.hintOverrides;
22392269 _elevation = config.elevation;
22402270 _thickness = config.thickness;
@@ -2282,6 +2312,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
22822312 AttributedString attributedIncreasedValue = _attributedIncreasedValue;
22832313 AttributedString attributedDecreasedValue = _attributedDecreasedValue;
22842314 AttributedString attributedHint = _attributedHint;
2315+ String tooltip = _tooltip;
22852316 TextDirection ? textDirection = _textDirection;
22862317 Set <SemanticsTag >? mergedTags = tags == null ? null : Set <SemanticsTag >.of (tags! );
22872318 TextSelection ? textSelection = _textSelection;
@@ -2336,6 +2367,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
23362367 attributedIncreasedValue = node._attributedIncreasedValue;
23372368 if (attributedDecreasedValue == null || attributedDecreasedValue.string == '' )
23382369 attributedDecreasedValue = node._attributedDecreasedValue;
2370+ if (tooltip == '' )
2371+ tooltip = node._tooltip;
23392372 if (node.tags != null ) {
23402373 mergedTags ?? = < SemanticsTag > {};
23412374 mergedTags! .addAll (node.tags! );
@@ -2385,6 +2418,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
23852418 attributedIncreasedValue: attributedIncreasedValue,
23862419 attributedDecreasedValue: attributedDecreasedValue,
23872420 attributedHint: attributedHint,
2421+ tooltip: tooltip,
23882422 textDirection: textDirection,
23892423 rect: rect,
23902424 transform: transform,
@@ -2457,6 +2491,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
24572491 decreasedValueAttributes: data.attributedDecreasedValue.attributes,
24582492 hint: data.attributedHint.string,
24592493 hintAttributes: data.attributedHint.attributes,
2494+ tooltip: data.tooltip,
24602495 textDirection: data.textDirection,
24612496 textSelectionBase: data.textSelection != null ? data.textSelection! .baseOffset : - 1 ,
24622497 textSelectionExtent: data.textSelection != null ? data.textSelection! .extentOffset : - 1 ,
@@ -2595,6 +2630,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
25952630 properties.add (AttributedStringProperty ('increasedValue' , _attributedIncreasedValue));
25962631 properties.add (AttributedStringProperty ('decreasedValue' , _attributedDecreasedValue));
25972632 properties.add (AttributedStringProperty ('hint' , _attributedHint));
2633+ properties.add (StringProperty ('tooltip' , _tooltip, defaultValue: '' ));
25982634 properties.add (EnumProperty <TextDirection >('textDirection' , _textDirection, defaultValue: null ));
25992635 properties.add (DiagnosticsProperty <SemanticsSortKey >('sortKey' , sortKey, defaultValue: null ));
26002636 if (_textSelection? .isValid ?? false )
@@ -3955,6 +3991,16 @@ class SemanticsConfiguration {
39553991 _hasBeenAnnotated = true ;
39563992 }
39573993
3994+ /// A textual description of the widget's tooltip.
3995+ ///
3996+ /// The reading direction is given by [textDirection] .
3997+ String get tooltip => _tooltip;
3998+ String _tooltip = '' ;
3999+ set tooltip (String tooltip) {
4000+ _tooltip = tooltip;
4001+ _hasBeenAnnotated = true ;
4002+ }
4003+
39584004 /// Provides hint values which override the default hints on supported
39594005 /// platforms.
39604006 SemanticsHintOverrides ? get hintOverrides => _hintOverrides;
@@ -4420,6 +4466,8 @@ class SemanticsConfiguration {
44204466 otherAttributedString: child._attributedHint,
44214467 otherTextDirection: child.textDirection,
44224468 );
4469+ if (_tooltip == '' )
4470+ _tooltip = child._tooltip;
44234471
44244472 _thickness = math.max (_thickness, child._thickness + child._elevation);
44254473
@@ -4442,6 +4490,7 @@ class SemanticsConfiguration {
44424490 .._attributedDecreasedValue = _attributedDecreasedValue
44434491 .._attributedHint = _attributedHint
44444492 .._hintOverrides = _hintOverrides
4493+ .._tooltip = _tooltip
44454494 .._elevation = _elevation
44464495 .._thickness = _thickness
44474496 .._flags = _flags
0 commit comments