diff --git a/packages/material_ui/lib/src/expansion_tile.dart b/packages/material_ui/lib/src/expansion_tile.dart index 3d59612ccc4..b77fbad2a0f 100644 --- a/packages/material_ui/lib/src/expansion_tile.dart +++ b/packages/material_ui/lib/src/expansion_tile.dart @@ -693,7 +693,9 @@ class _ExpansionTileState extends State { return Semantics( // Live region used to announce state changes (e.g., "expanded" or "collapsed") // without taking focus. - // blockNode prevents this node from being part of the focus traversal. + // The container ensures the live region forms the node that blockNode + // removes from focus traversal. + container: true, label: semanticsHint, liveRegion: true, accessibilityFocusBlockType: AccessibilityFocusBlockType.blockNode, diff --git a/packages/material_ui/pending_changelogs/change_2026_08_06_expansion_tile_widget_span.yaml b/packages/material_ui/pending_changelogs/change_2026_08_06_expansion_tile_widget_span.yaml new file mode 100644 index 00000000000..8b397ca1d4f --- /dev/null +++ b/packages/material_ui/pending_changelogs/change_2026_08_06_expansion_tile_widget_span.yaml @@ -0,0 +1,3 @@ +changelog: | + - Fixes an Android semantics assertion when an `ExpansionTile` is embedded in a `WidgetSpan`. +version: patch diff --git a/packages/material_ui/test/expansion_tile_test.dart b/packages/material_ui/test/expansion_tile_test.dart index bfdb8b020b1..ee3436261f6 100644 --- a/packages/material_ui/test/expansion_tile_test.dart +++ b/packages/material_ui/test/expansion_tile_test.dart @@ -2230,6 +2230,34 @@ void main() { ); }); group('Semantics tests for android platform', () { + // Regression test for https://github.com/flutter/flutter/issues/188298. + testWidgets('ExpansionTile supports being embedded in a WidgetSpan', ( + WidgetTester tester, + ) async { + final SemanticsHandle handle = tester.ensureSemantics(); + + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: Text.rich( + TextSpan( + children: [ + WidgetSpan( + child: ExpansionTile( + title: Text('Header'), + children: [Text('Details')], + ), + ), + ], + ), + ), + ), + ), + ); + expect(find.text('Header'), findsOneWidget); + handle.dispose(); + }, variant: const TargetPlatformVariant({TargetPlatform.android})); + testWidgets('Semantics liveregion updates when expansion state changes', ( WidgetTester tester, ) async {