@@ -316,6 +316,7 @@ class SemanticsData with Diagnosticable {
316
316
required this .attributedIncreasedValue,
317
317
required this .attributedDecreasedValue,
318
318
required this .attributedHint,
319
+ required this .tooltip,
319
320
required this .textDirection,
320
321
required this .rect,
321
322
required this .elevation,
@@ -339,6 +340,7 @@ class SemanticsData with Diagnosticable {
339
340
assert (attributedDecreasedValue != null ),
340
341
assert (attributedIncreasedValue != null ),
341
342
assert (attributedHint != null ),
343
+ assert (tooltip == '' || textDirection != null , 'A SemanticsData object with tooltip "$tooltip " had a null textDirection.' ),
342
344
assert (attributedLabel.string == '' || textDirection != null , 'A SemanticsData object with label "${attributedLabel .string }" had a null textDirection.' ),
343
345
assert (attributedValue.string == '' || textDirection != null , 'A SemanticsData object with value "${attributedValue .string }" had a null textDirection.' ),
344
346
assert (attributedDecreasedValue.string == '' || textDirection != null , 'A SemanticsData object with decreasedValue "${attributedDecreasedValue .string }" had a null textDirection.' ),
@@ -429,6 +431,11 @@ class SemanticsData with Diagnosticable {
429
431
/// See also [hint] , which exposes just the raw text.
430
432
final AttributedString attributedHint;
431
433
434
+ /// A textual description of the widget's tooltip.
435
+ ///
436
+ /// The reading direction is given by [textDirection] .
437
+ final String tooltip;
438
+
432
439
/// The reading direction for the text in [label] , [value] ,
433
440
/// [increasedValue] , [decreasedValue] , and [hint] .
434
441
final TextDirection ? textDirection;
@@ -587,6 +594,7 @@ class SemanticsData with Diagnosticable {
587
594
properties.add (AttributedStringProperty ('increasedValue' , attributedIncreasedValue));
588
595
properties.add (AttributedStringProperty ('decreasedValue' , attributedDecreasedValue));
589
596
properties.add (AttributedStringProperty ('hint' , attributedHint));
597
+ properties.add (StringProperty ('tooltip' , tooltip, defaultValue: '' ));
590
598
properties.add (EnumProperty <TextDirection >('textDirection' , textDirection, defaultValue: null ));
591
599
if (textSelection? .isValid ?? false )
592
600
properties.add (MessageProperty ('textSelection' , '[${textSelection !.start }, ${textSelection !.end }]' ));
@@ -610,6 +618,7 @@ class SemanticsData with Diagnosticable {
610
618
&& other.attributedIncreasedValue == attributedIncreasedValue
611
619
&& other.attributedDecreasedValue == attributedDecreasedValue
612
620
&& other.attributedHint == attributedHint
621
+ && other.tooltip == tooltip
613
622
&& other.textDirection == textDirection
614
623
&& other.rect == rect
615
624
&& setEquals (other.tags, tags)
@@ -637,6 +646,7 @@ class SemanticsData with Diagnosticable {
637
646
attributedIncreasedValue,
638
647
attributedDecreasedValue,
639
648
attributedHint,
649
+ tooltip,
640
650
textDirection,
641
651
rect,
642
652
tags,
@@ -648,8 +658,8 @@ class SemanticsData with Diagnosticable {
648
658
scrollExtentMin,
649
659
platformViewId,
650
660
maxValueLength,
651
- currentValueLength,
652
661
Object .hash (
662
+ currentValueLength,
653
663
transform,
654
664
elevation,
655
665
thickness,
@@ -785,6 +795,7 @@ class SemanticsProperties extends DiagnosticableTree {
785
795
this .decreasedValue,
786
796
this .attributedDecreasedValue,
787
797
this .hint,
798
+ this .tooltip,
788
799
this .attributedHint,
789
800
this .hintOverrides,
790
801
this .textDirection,
@@ -1178,6 +1189,16 @@ class SemanticsProperties extends DiagnosticableTree {
1178
1189
/// * [hint] for a plain string version of this property.
1179
1190
final AttributedString ? attributedHint;
1180
1191
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
+
1181
1202
/// Provides hint values which override the default hints on supported
1182
1203
/// platforms.
1183
1204
///
@@ -1469,6 +1490,7 @@ class SemanticsProperties extends DiagnosticableTree {
1469
1490
properties.add (AttributedStringProperty ('attributedDecreasedValue' , attributedDecreasedValue, defaultValue: null ));
1470
1491
properties.add (StringProperty ('hint' , hint, defaultValue: null ));
1471
1492
properties.add (AttributedStringProperty ('attributedHint' , attributedHint, defaultValue: null ));
1493
+ properties.add (StringProperty ('tooltip' , tooltip));
1472
1494
properties.add (EnumProperty <TextDirection >('textDirection' , textDirection, defaultValue: null ));
1473
1495
properties.add (DiagnosticsProperty <SemanticsSortKey >('sortKey' , sortKey, defaultValue: null ));
1474
1496
properties.add (DiagnosticsProperty <SemanticsHintOverrides >('hintOverrides' , hintOverrides, defaultValue: null ));
@@ -1898,6 +1920,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
1898
1920
|| _attributedValue != config.attributedValue
1899
1921
|| _attributedIncreasedValue != config.attributedIncreasedValue
1900
1922
|| _attributedDecreasedValue != config.attributedDecreasedValue
1923
+ || _tooltip != config.tooltip
1901
1924
|| _flags != config._flags
1902
1925
|| _textDirection != config.textDirection
1903
1926
|| _sortKey != config._sortKey
@@ -2027,6 +2050,12 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2027
2050
AttributedString get attributedHint => _attributedHint;
2028
2051
AttributedString _attributedHint = _kEmptyConfig.attributedHint;
2029
2052
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
+
2030
2059
/// The elevation along the z-axis at which the [rect] of this [SemanticsNode]
2031
2060
/// is located above its parent.
2032
2061
///
@@ -2235,6 +2264,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2235
2264
_attributedIncreasedValue = config.attributedIncreasedValue;
2236
2265
_attributedDecreasedValue = config.attributedDecreasedValue;
2237
2266
_attributedHint = config.attributedHint;
2267
+ _tooltip = config.tooltip;
2238
2268
_hintOverrides = config.hintOverrides;
2239
2269
_elevation = config.elevation;
2240
2270
_thickness = config.thickness;
@@ -2282,6 +2312,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2282
2312
AttributedString attributedIncreasedValue = _attributedIncreasedValue;
2283
2313
AttributedString attributedDecreasedValue = _attributedDecreasedValue;
2284
2314
AttributedString attributedHint = _attributedHint;
2315
+ String tooltip = _tooltip;
2285
2316
TextDirection ? textDirection = _textDirection;
2286
2317
Set <SemanticsTag >? mergedTags = tags == null ? null : Set <SemanticsTag >.of (tags! );
2287
2318
TextSelection ? textSelection = _textSelection;
@@ -2336,6 +2367,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2336
2367
attributedIncreasedValue = node._attributedIncreasedValue;
2337
2368
if (attributedDecreasedValue == null || attributedDecreasedValue.string == '' )
2338
2369
attributedDecreasedValue = node._attributedDecreasedValue;
2370
+ if (tooltip == '' )
2371
+ tooltip = node._tooltip;
2339
2372
if (node.tags != null ) {
2340
2373
mergedTags ?? = < SemanticsTag > {};
2341
2374
mergedTags! .addAll (node.tags! );
@@ -2385,6 +2418,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2385
2418
attributedIncreasedValue: attributedIncreasedValue,
2386
2419
attributedDecreasedValue: attributedDecreasedValue,
2387
2420
attributedHint: attributedHint,
2421
+ tooltip: tooltip,
2388
2422
textDirection: textDirection,
2389
2423
rect: rect,
2390
2424
transform: transform,
@@ -2457,6 +2491,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2457
2491
decreasedValueAttributes: data.attributedDecreasedValue.attributes,
2458
2492
hint: data.attributedHint.string,
2459
2493
hintAttributes: data.attributedHint.attributes,
2494
+ tooltip: data.tooltip,
2460
2495
textDirection: data.textDirection,
2461
2496
textSelectionBase: data.textSelection != null ? data.textSelection! .baseOffset : - 1 ,
2462
2497
textSelectionExtent: data.textSelection != null ? data.textSelection! .extentOffset : - 1 ,
@@ -2595,6 +2630,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin {
2595
2630
properties.add (AttributedStringProperty ('increasedValue' , _attributedIncreasedValue));
2596
2631
properties.add (AttributedStringProperty ('decreasedValue' , _attributedDecreasedValue));
2597
2632
properties.add (AttributedStringProperty ('hint' , _attributedHint));
2633
+ properties.add (StringProperty ('tooltip' , _tooltip, defaultValue: '' ));
2598
2634
properties.add (EnumProperty <TextDirection >('textDirection' , _textDirection, defaultValue: null ));
2599
2635
properties.add (DiagnosticsProperty <SemanticsSortKey >('sortKey' , sortKey, defaultValue: null ));
2600
2636
if (_textSelection? .isValid ?? false )
@@ -3955,6 +3991,16 @@ class SemanticsConfiguration {
3955
3991
_hasBeenAnnotated = true ;
3956
3992
}
3957
3993
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
+
3958
4004
/// Provides hint values which override the default hints on supported
3959
4005
/// platforms.
3960
4006
SemanticsHintOverrides ? get hintOverrides => _hintOverrides;
@@ -4420,6 +4466,8 @@ class SemanticsConfiguration {
4420
4466
otherAttributedString: child._attributedHint,
4421
4467
otherTextDirection: child.textDirection,
4422
4468
);
4469
+ if (_tooltip == '' )
4470
+ _tooltip = child._tooltip;
4423
4471
4424
4472
_thickness = math.max (_thickness, child._thickness + child._elevation);
4425
4473
@@ -4442,6 +4490,7 @@ class SemanticsConfiguration {
4442
4490
.._attributedDecreasedValue = _attributedDecreasedValue
4443
4491
.._attributedHint = _attributedHint
4444
4492
.._hintOverrides = _hintOverrides
4493
+ .._tooltip = _tooltip
4445
4494
.._elevation = _elevation
4446
4495
.._thickness = _thickness
4447
4496
.._flags = _flags
0 commit comments