Skip to content

Commit 153fce4

Browse files
authored
Revert "Fix ExpansionTile hint for Android (#120881)" (#121624)
This reverts commit fd65fd1.
1 parent c8aa37d commit 153fce4

File tree

84 files changed

+81
-1488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+81
-1488
lines changed

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/rendering.dart';
65
import 'package:flutter/widgets.dart';
76

87
import 'color_scheme.dart';
@@ -12,7 +11,6 @@ import 'icons.dart';
1211
import 'list_tile.dart';
1312
import 'list_tile_theme.dart';
1413
import 'material.dart';
15-
import 'material_localizations.dart';
1614
import 'theme.dart';
1715

1816
const Duration _kExpand = Duration(milliseconds: 200);
@@ -360,9 +358,6 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
360358
}
361359

362360
void _handleTap() {
363-
final TextDirection textDirection = Directionality.of(context);
364-
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
365-
final String stateHint = _isExpanded ? localizations.expandedHint : localizations.collapsedHint;
366361
setState(() {
367362
_isExpanded = !_isExpanded;
368363
if (_isExpanded) {
@@ -380,7 +375,6 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
380375
PageStorage.maybeOf(context)?.writeState(context, _isExpanded);
381376
});
382377
widget.onExpansionChanged?.call(_isExpanded);
383-
SemanticsService.announce(stateHint, textDirection);
384378
}
385379

386380
// Platform or null affinity defaults to trailing.
@@ -499,10 +493,6 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
499493
final ExpansionTileThemeData expansionTileTheme = ExpansionTileTheme.of(context);
500494
final bool closed = !_isExpanded && _controller.isDismissed;
501495
final bool shouldRemoveChildren = closed && !widget.maintainState;
502-
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
503-
final String onTapHint = _isExpanded
504-
? localizations.expansionTileExpandedTapHint
505-
: localizations.expansionTileCollapsedTapHint;
506496

507497
final Widget result = Offstage(
508498
offstage: closed,
@@ -518,13 +508,10 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
518508
),
519509
);
520510

521-
return Semantics(
522-
onTapHint: onTapHint,
523-
child: AnimatedBuilder(
524-
animation: _controller.view,
525-
builder: _buildChildren,
526-
child: shouldRemoveChildren ? null : result,
527-
),
511+
return AnimatedBuilder(
512+
animation: _controller.view,
513+
builder: _buildChildren,
514+
child: shouldRemoveChildren ? null : result,
528515
);
529516
}
530517
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -452,18 +452,6 @@ abstract class MaterialLocalizations {
452452
/// The semantics hint to describe the tap action on a collapsed [ExpandIcon].
453453
String get collapsedIconTapHint => 'Expand';
454454

455-
/// The semantics hint to describe the tap action on an expanded [ExpansionTile].
456-
String get expansionTileExpandedTapHint => 'Collapse';
457-
458-
/// The semantics hint to describe the tap action on a collapsed [ExpansionTile].
459-
String get expansionTileCollapsedTapHint => 'Expand for more details';
460-
461-
/// The semantics hint to describe the [ExpansionTile] expanded state.
462-
String get expandedHint => 'Collapsed';
463-
464-
/// The semantics hint to describe the [ExpansionTile] collapsed state.
465-
String get collapsedHint => 'Expanded';
466-
467455
/// The label for the [TextField]'s character counter.
468456
String remainingTextFieldCharacterCount(int remaining);
469457

@@ -1188,18 +1176,6 @@ class DefaultMaterialLocalizations implements MaterialLocalizations {
11881176
@override
11891177
String get collapsedIconTapHint => 'Expand';
11901178

1191-
@override
1192-
String get expansionTileExpandedTapHint => 'Collapse';
1193-
1194-
@override
1195-
String get expansionTileCollapsedTapHint => 'Expand for more details';
1196-
1197-
@override
1198-
String get expandedHint => 'Collapsed';
1199-
1200-
@override
1201-
String get collapsedHint => 'Expanded';
1202-
12031179
@override
12041180
String get refreshIndicatorSemanticLabel => 'Refresh';
12051181

packages/flutter/test/material/expansion_tile_test.dart

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -696,106 +696,6 @@ void main() {
696696
expect(listTile.trailing, isNull);
697697
});
698698

699-
testWidgets('ExpansionTile Semantics', (WidgetTester tester) async {
700-
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
701-
final SemanticsHandle handle = tester.ensureSemantics();
702-
const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations();
703-
await tester.pumpWidget(const MaterialApp(
704-
home: Material(
705-
child: Column(
706-
children: <Widget>[
707-
ExpansionTile(
708-
title: Text('Title'),
709-
),
710-
ExpansionTile(
711-
initiallyExpanded: true,
712-
title: Text('Title'),
713-
),
714-
],
715-
),
716-
),
717-
));
718-
719-
// Focus the first ExpansionTile.
720-
tester.binding.focusManager.primaryFocus?.nextFocus();
721-
await tester.pumpAndSettle();
722-
723-
// The first ExpansionTile should be collapsed and focused.
724-
expect(
725-
tester.getSemantics(find.byType(ExpansionTile).first),
726-
matchesSemantics(
727-
hasTapAction: true,
728-
hasEnabledState: true,
729-
isEnabled: true,
730-
isFocused: true,
731-
isFocusable: true,
732-
label: 'Title',
733-
textDirection: TextDirection.ltr,
734-
// The hint should be the opposite of the current state.
735-
// The first ExpansionTile is collapsed, so the hint should be
736-
// "double tap to expand".
737-
onTapHint: localizations.expansionTileCollapsedTapHint,
738-
),
739-
);
740-
741-
// The second ExpansionTile should be expanded and not focused.
742-
expect(
743-
tester.getSemantics(find.byType(ExpansionTile).last),
744-
matchesSemantics(
745-
hasTapAction: true,
746-
hasEnabledState: true,
747-
isEnabled: true,
748-
isFocusable: true,
749-
label: 'Title',
750-
textDirection: TextDirection.ltr,
751-
// The hint should be the opposite of the current state.
752-
// The second ExpansionTile is expanded, so the hint should be
753-
// "double tap to collapse".
754-
onTapHint: localizations.expansionTileExpandedTapHint,
755-
),
756-
);
757-
handle.dispose();
758-
});
759-
760-
testWidgets('ExpansionTile Semantics announcement', (WidgetTester tester) async {
761-
final SemanticsHandle handle = tester.ensureSemantics();
762-
const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations();
763-
await tester.pumpWidget(
764-
const MaterialApp(
765-
home: Material(
766-
child: ExpansionTile(
767-
title: Text('Title'),
768-
children: <Widget>[
769-
SizedBox(height: 100, width: 100),
770-
],
771-
),
772-
),
773-
),
774-
);
775-
776-
// There is no semantics announcement without tap action.
777-
expect(tester.takeAnnouncements(), isEmpty);
778-
779-
// Tap the title to expand ExpansionTile.
780-
await tester.tap(find.text('Title'));
781-
await tester.pumpAndSettle();
782-
783-
// The announcement should be the opposite of the current state.
784-
// The ExpansionTile is expanded, so the announcement should be
785-
// "Expanded".
786-
expect(tester.takeAnnouncements().first.message, localizations.collapsedHint);
787-
788-
// Tap the title to collapse ExpansionTile.
789-
await tester.tap(find.text('Title'));
790-
await tester.pumpAndSettle();
791-
792-
// The announcement should be the opposite of the current state.
793-
// The ExpansionTile is collapsed, so the announcement should be
794-
// "Collapsed".
795-
expect(tester.takeAnnouncements().first.message, localizations.expandedHint);
796-
handle.dispose();
797-
});
798-
799699
group('Material 2', () {
800700
// Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
801701
// is turned on by default, these tests can be removed.

packages/flutter/test/material/localizations_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ void main() {
7575
expect(localizations.reorderItemDown, isNotNull);
7676
expect(localizations.reorderItemLeft, isNotNull);
7777
expect(localizations.reorderItemRight, isNotNull);
78-
expect(localizations.expandedIconTapHint, isNotNull);
79-
expect(localizations.collapsedIconTapHint, isNotNull);
80-
expect(localizations.expandedHint, isNotNull);
81-
expect(localizations.collapsedHint, isNotNull);
8278
expect(localizations.keyboardKeyAlt, isNotNull);
8379
expect(localizations.keyboardKeyAltGraph, isNotNull);
8480
expect(localizations.keyboardKeyBackspace, isNotNull);

0 commit comments

Comments
 (0)