Skip to content

Commit 7549925

Browse files
author
Casey Hillers
authored
Revert "Adds API in semanticsconfiguration to decide how to merge child semanticsConfigurations (#110730)" (#116839)
This reverts commit 352ad3a.
1 parent be5c389 commit 7549925

File tree

6 files changed

+67
-833
lines changed

6 files changed

+67
-833
lines changed

packages/flutter/lib/src/material/input_decorator.dart

+19-85
Original file line numberDiff line numberDiff line change
@@ -1326,35 +1326,6 @@ class _RenderDecoration extends RenderBox with SlottedContainerRenderObjectMixin
13261326
return Size.zero;
13271327
}
13281328

1329-
ChildSemanticsConfigurationsResult _childSemanticsConfigurationDelegate(List<SemanticsConfiguration> childConfigs) {
1330-
final ChildSemanticsConfigurationsResultBuilder builder = ChildSemanticsConfigurationsResultBuilder();
1331-
List<SemanticsConfiguration>? prefixMergeGroup;
1332-
List<SemanticsConfiguration>? suffixMergeGroup;
1333-
for (final SemanticsConfiguration childConfig in childConfigs) {
1334-
if (childConfig.tagsChildrenWith(_InputDecoratorState._kPrefixSemanticsTag)) {
1335-
prefixMergeGroup ??= <SemanticsConfiguration>[];
1336-
prefixMergeGroup.add(childConfig);
1337-
} else if (childConfig.tagsChildrenWith(_InputDecoratorState._kSuffixSemanticsTag)) {
1338-
suffixMergeGroup ??= <SemanticsConfiguration>[];
1339-
suffixMergeGroup.add(childConfig);
1340-
} else {
1341-
builder.markAsMergeUp(childConfig);
1342-
}
1343-
}
1344-
if (prefixMergeGroup != null) {
1345-
builder.markAsSiblingMergeGroup(prefixMergeGroup);
1346-
}
1347-
if (suffixMergeGroup != null) {
1348-
builder.markAsSiblingMergeGroup(suffixMergeGroup);
1349-
}
1350-
return builder.build();
1351-
}
1352-
1353-
@override
1354-
void describeSemanticsConfiguration(SemanticsConfiguration config) {
1355-
config.childConfigurationsDelegate = _childSemanticsConfigurationDelegate;
1356-
}
1357-
13581329
@override
13591330
void performLayout() {
13601331
final BoxConstraints constraints = this.constraints;
@@ -1742,16 +1713,12 @@ class _AffixText extends StatelessWidget {
17421713
this.text,
17431714
this.style,
17441715
this.child,
1745-
this.semanticsSortKey,
1746-
required this.semanticsTag,
17471716
});
17481717

17491718
final bool labelIsFloating;
17501719
final String? text;
17511720
final TextStyle? style;
17521721
final Widget? child;
1753-
final SemanticsSortKey? semanticsSortKey;
1754-
final SemanticsTag semanticsTag;
17551722

17561723
@override
17571724
Widget build(BuildContext context) {
@@ -1761,11 +1728,7 @@ class _AffixText extends StatelessWidget {
17611728
duration: _kTransitionDuration,
17621729
curve: _kTransitionCurve,
17631730
opacity: labelIsFloating ? 1.0 : 0.0,
1764-
child: Semantics(
1765-
sortKey: semanticsSortKey,
1766-
tagForChildren: semanticsTag,
1767-
child: child ?? (text == null ? null : Text(text!, style: style)),
1768-
),
1731+
child: child ?? (text == null ? null : Text(text!, style: style)),
17691732
),
17701733
);
17711734
}
@@ -1936,11 +1899,6 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
19361899
late AnimationController _floatingLabelController;
19371900
late AnimationController _shakingLabelController;
19381901
final _InputBorderGap _borderGap = _InputBorderGap();
1939-
static const OrdinalSortKey _kPrefixSemanticsSortOrder = OrdinalSortKey(0);
1940-
static const OrdinalSortKey _kInputSemanticsSortOrder = OrdinalSortKey(1);
1941-
static const OrdinalSortKey _kSuffixSemanticsSortOrder = OrdinalSortKey(2);
1942-
static const SemanticsTag _kPrefixSemanticsTag = SemanticsTag('_InputDecoratorState.prefix');
1943-
static const SemanticsTag _kSuffixSemanticsTag = SemanticsTag('_InputDecoratorState.suffix');
19441902

19451903
@override
19461904
void initState() {
@@ -2260,42 +2218,22 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
22602218
),
22612219
);
22622220

2263-
final bool hasPrefix = decoration.prefix != null || decoration.prefixText != null;
2264-
final bool hasSuffix = decoration.suffix != null || decoration.suffixText != null;
2265-
2266-
Widget? input = widget.child;
2267-
// If at least two out of the three are visible, it needs semantics sort
2268-
// order.
2269-
final bool needsSemanticsSortOrder = widget._labelShouldWithdraw && (input != null ? (hasPrefix || hasSuffix) : (hasPrefix && hasSuffix));
2270-
2271-
final Widget? prefix = hasPrefix
2272-
? _AffixText(
2273-
labelIsFloating: widget._labelShouldWithdraw,
2274-
text: decoration.prefixText,
2275-
style: MaterialStateProperty.resolveAs(decoration.prefixStyle, materialState) ?? hintStyle,
2276-
semanticsSortKey: needsSemanticsSortOrder ? _kPrefixSemanticsSortOrder : null,
2277-
semanticsTag: _kPrefixSemanticsTag,
2278-
child: decoration.prefix,
2279-
)
2280-
: null;
2281-
2282-
final Widget? suffix = hasSuffix
2283-
? _AffixText(
2284-
labelIsFloating: widget._labelShouldWithdraw,
2285-
text: decoration.suffixText,
2286-
style: MaterialStateProperty.resolveAs(decoration.suffixStyle, materialState) ?? hintStyle,
2287-
semanticsSortKey: needsSemanticsSortOrder ? _kSuffixSemanticsSortOrder : null,
2288-
semanticsTag: _kSuffixSemanticsTag,
2289-
child: decoration.suffix,
2290-
)
2291-
: null;
2292-
2293-
if (input != null && needsSemanticsSortOrder) {
2294-
input = Semantics(
2295-
sortKey: _kInputSemanticsSortOrder,
2296-
child: input,
2221+
final Widget? prefix = decoration.prefix == null && decoration.prefixText == null ? null :
2222+
_AffixText(
2223+
labelIsFloating: widget._labelShouldWithdraw,
2224+
text: decoration.prefixText,
2225+
style: MaterialStateProperty.resolveAs(decoration.prefixStyle, materialState) ?? hintStyle,
2226+
child: decoration.prefix,
22972227
);
2298-
}
2228+
2229+
final Widget? suffix = decoration.suffix == null && decoration.suffixText == null ? null :
2230+
_AffixText(
2231+
labelIsFloating: widget._labelShouldWithdraw,
2232+
text: decoration.suffixText,
2233+
style: MaterialStateProperty.resolveAs(decoration.suffixStyle, materialState) ?? hintStyle,
2234+
child: decoration.suffix,
2235+
);
2236+
22992237

23002238
final bool decorationIsDense = decoration.isDense ?? false;
23012239
final double iconSize = decorationIsDense ? 18.0 : 24.0;
@@ -2334,9 +2272,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
23342272
color: _getPrefixIconColor(themeData, defaults),
23352273
size: iconSize,
23362274
),
2337-
child: Semantics(
2338-
child: decoration.prefixIcon,
2339-
),
2275+
child: decoration.prefixIcon!,
23402276
),
23412277
),
23422278
),
@@ -2361,9 +2297,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
23612297
color: _getSuffixIconColor(themeData, defaults),
23622298
size: iconSize,
23632299
),
2364-
child: Semantics(
2365-
child: decoration.suffixIcon,
2366-
),
2300+
child: decoration.suffixIcon!,
23672301
),
23682302
),
23692303
),
@@ -2440,7 +2374,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
24402374
isDense: decoration.isDense,
24412375
visualDensity: themeData.visualDensity,
24422376
icon: icon,
2443-
input: input,
2377+
input: widget.child,
24442378
label: label,
24452379
hint: hint,
24462380
prefix: prefix,

0 commit comments

Comments
 (0)