Repository navigation
[go_router] Semantics disappearing in ShellRoute #135656
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- create a new project and install go_router
flutter pub add go_router. - Create a GoRouter configuration as seen in the attached code sample.
- Create the Home widget and the ShellOne widget.
- Enable
showSemanticsDebuggerinMaterialApp. - Run the code.
Expected results
This sample app contains a ShellRoute with an internal GoRoute.
The GoRoute displays the Home widget, which is just a Placeholder with a custom Semantics label "HOME".
The ShellRoute has a Column with a Placeholder at the top, with a height of 100 px, and a custom Semantics label of SHELL ONE.
When running the app, you can see the two Placeholders (screenshot 1)
One would also expect to see the two Semantics labels, the SHELL ONE and the HOME.
Actual results
However, the semantics label of the ShellOne Widget is gone, and only the semantics of the Home widget is visible.
See screenshot 2.
This causes that, for example, a navigation bar in a ShellRoute doesn't show semantics, which affects both user accessibility and also integration testing based off accessibility labels (e.g. Maestro).
My only guess is that ShellRoute injects a BlockSemantics as part of the widget builder, which wraps the original child in a Navigator, as it can be seen in the Widget inspector tree:
See screenshot 3.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Flutter Demo',
showSemanticsDebugger: true,
routerConfig: GoRouter(routes: [
ShellRoute(
builder: (context, state, child) => ShellOne(child: child),
routes: [
GoRoute(
path: '/',
builder: (context, state) => const Home(),
)
],
)
]),
);
}
}
class Home extends StatelessWidget {
const Home({super.key});
@override
Widget build(BuildContext context) {
return Semantics(
label: 'HOME',
child: const Placeholder(),
);
}
}
class ShellOne extends StatelessWidget {
const ShellOne({
super.key,
required this.child,
});
final Widget child;
@override
Widget build(BuildContext context) {
return Column(
children: [
Semantics(
label: 'SHELL ONE',
child: const SizedBox(
height: 100,
child: Placeholder(),
),
),
Expanded(child: child),
],
);
}
}Screenshots or Video
Logs
Logs
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
(go_router_nested_semantics:57586): Gdk-CRITICAL **: 10:47:31.418: gdk_window_get_state: assertion 'GDK_IS_WINDOW (window)' failed
Debug service listening on ws://127.0.0.1:43403/kvDz0Hm_Sus=/ws
Syncing files to device Linux...Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.13.5, on Ubuntu 22.04.3 LTS 6.2.0-33-generic, locale en_US.UTF-8)
• Flutter version 3.13.5 on channel stable at /home/miquel/dev/tools/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 12fccda598 (9 days ago), 2023-09-19 13:56:11 -0700
• Engine revision bd986c5ed2
• Dart version 3.1.2
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /home/miquel/Android/Sdk
• Platform android-33, build-tools 33.0.1
• Java binary at:
/home/miquel/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Homebrew clang version 15.0.5
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2
[✓] Android Studio (version 2022.2)
• Android Studio at /home/miquel/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] Android Studio (version 2022.3)
• Android Studio at /home/miquel/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.10406996
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Community Edition (version 2023.2)
• IntelliJ at /home/miquel/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/232.9921.47
• Flutter plugin version 75.1.4
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version unknown)
• VS Code at /snap/code/current
• Flutter extension version 3.70.0
✗ Unable to determine VS Code version.
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.3 LTS 6.2.0-33-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.187
[✓] Network resources
• All expected network resources are available.
• No issues found!


Activity
miquelbeltran commentedon Sep 28, 2023
One thing I just discovered, is that switching the order in the
ColumnI am able to see the Semantics of theShellOnewidget:When I switch the column order, the semantics are gone:
miquelbeltran commentedon Sep 28, 2023
And I use
VerticalDirection.up... I am able to display the top Shell widget if I invert theColumnorder. Sort of a workaround hack?huycozy commentedon Sep 28, 2023
Thanks for your report. Reproduced this issue and the workaround above. Labelling this as a go_router issue although this is more like a Framework issue with nested routes.
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.13.6, on macOS 13.6 22G120 darwin-x64, locale en-VN) • Flutter version 3.13.6 on channel stable at /Users/huynq/Documents/GitHub/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ead455963c (26 hours ago), 2023-09-26 18:28:17 -0700 • Engine revision a794cf2681 • Dart version 3.1.3 • DevTools version 2.25.0 [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/huynq/Library/Android/sdk • Platform android-34, build-tools 32.0.0 • ANDROID_HOME = /Users/huynq/Library/Android/sdk • Java binary at: /Applications/Android Studio Giraffe.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 14.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E222b • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.3) • Android Studio at /Applications/Android Studio Giraffe.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio Flamingo.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.82.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.72.0 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 11 (API 30) • iPhone (mobile) • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios • iOS 15.7.9 19H365 • macOS (desktop) • macos • darwin-x64 • macOS 13.6 22G120 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 117.0.5938.132 [✓] Network resources • All expected network resources are available. • No issues found!25 remaining items
chunhtai commentedon Oct 7, 2024
This is probably due to BlockSemantics that each route uses to block the semantics from other routes below. Wrap the shellRoute child with Semantics(container:true, child: child) should workaround this issue
rkpontes commentedon Oct 7, 2024
Semantics(container:true, child: child)Worked to me.
[go_router] Fix ShellRoute chrome dropped from semantics tree by Moda…
[go_router] Fix ShellRoute chrome dropped from semantics tree by Moda…
[go_router] Fix ShellRoute chrome dropped from semantics tree by Moda…
[go_router] Fix ShellRoute chrome dropped from semantics tree by Moda…
github-actions commentedon Oct 6, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.