Skip to content

[go_router] Semantics disappearing in ShellRoute #135656

Closed
flutter/packages
#12353

Description

@miquelbeltran

Is there an existing issue for this?

Steps to reproduce

  1. create a new project and install go_router flutter pub add go_router.
  2. Create a GoRouter configuration as seen in the attached code sample.
  3. Create the Home widget and the ShellOne widget.
  4. Enable showSemanticsDebugger in MaterialApp.
  5. 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

Screenshots / Video demonstration

Screenshot from 2023-09-28 10-14-48

Screenshot from 2023-09-28 10-15-01

image

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

  1. miquelbeltran commented on Sep 28, 2023

    @miquelbeltran
    MemberAuthor

    One thing I just discovered, is that switching the order in the Column I am able to see the Semantics of the ShellOne widget:

        return Column(
          children: [
            Expanded(child: child),
            Semantics(
              label: 'SHELL ONE',
              child: const SizedBox(
                height: 100,
                child: Placeholder(),
              ),
            ),
          ],
        );

    image

    When I switch the column order, the semantics are gone:

        return Column(
          children: [
            Semantics(
              label: 'SHELL ONE',
              child: const SizedBox(
                height: 100,
                child: Placeholder(),
              ),
            ),
            Expanded(child: child),
          ],
        );

    image

  2. miquelbeltran commented on Sep 28, 2023

    @miquelbeltran
    MemberAuthor

    And I use VerticalDirection.up... I am able to display the top Shell widget if I invert the Column order. Sort of a workaround hack?

        return Column(
          verticalDirection: VerticalDirection.up,
          children: [
            Expanded(child: child),
            Semantics(
              label: 'SHELL ONE',
              child: const SizedBox(
                height: 100,
                child: Placeholder(),
              ),
            ),
          ],
        );

    image

  3. added
    in triagePresently being triaged by the triage team
    on Sep 28, 2023
  4. huycozy commented on Sep 28, 2023

    @huycozy
    Member

    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!
    [!] Flutter (Channel master, 3.15.0-11.0.pre.10, on macOS 13.6 22G120 darwin-x64, locale en-VN)
        • Flutter version 3.15.0-11.0.pre.10 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 21ad7122a1 (87 minutes ago), 2023-09-27 18:42:16 -0700
        • Engine revision f70f65f7a6
        • Dart version 3.2.0 (build 3.2.0-199.0.dev)
        • DevTools version 2.28.0-dev.12
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] 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.
    
    ! Doctor found issues in 1 category.
  5. added
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    fyi-frameworkFor the attention of Framework team
    and removed
    in triagePresently being triaged by the triage team
    on Sep 28, 2023
  6. 25 remaining items

  7. chunhtai commented on Oct 7, 2024

    @chunhtai
    Contributor

    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

  8. rkpontes commented on Oct 7, 2024

    @rkpontes

    Semantics(container:true, child: child)

    Worked to me.

  9. added and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 26, 2026
  10. github-actions commented on Oct 6, 2026

    @github-actions

    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 -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)found in release: 3.13Found to occur in 3.13found in release: 3.15Found to occur in 3.15has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions