Skip to content

semanticsIdentifier of Text widget does not applied Semantic to it when used in Dialog widget with showDialog #180894

@Purvik

Description

@Purvik

Steps to reproduce

Use below dartpad link where I have added this example to reproduce the issue.
Dart pad link

Run the application and open inspect console and paste
document.querySelector('[aria-label="Enable accessibility"]').click(); to enable element selection.

Encounter if we use below only, Text element won't be identified.

Text( 'I should have the Semantics', semanticsIdentifier:'From Text Parameter',) 

However, if we use below, Text element will be identified.

Semantics(identifier: 'From Semantics',container: true, child: Text( 'I should have the Semantics', semanticsIdentifier:'From Text Parameter',) )

Whaat would be the reason for first part of code where Semantics are not identified using the Text paramenter?

Expected results

It should identify the Text element same as what it can do with Semantics widget having container as true.

Actual results

It's not identifying Text element with semanticsIdentifier parameter only.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const DialogTextSemantics(),
    );
  }
}

class DialogTextSemantics extends StatefulWidget {
  const DialogTextSemantics({super.key});

  @override
  State<DialogTextSemantics> createState() => _DialogTextSemanticsState();
}

class _DialogTextSemanticsState extends State<DialogTextSemantics> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            showDialog(
                context: context,
                builder: (bContext) {
                  return Material(
                    color: Colors.transparent,
                    child: Dialog(
                      shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(4)),
                      child: SizedBox(
                        width: 800,
                        child: Padding(
                          padding: const EdgeInsets.all(16.0),
                          child: Column(
                            mainAxisSize: MainAxisSize.min,
                            children: [
                              Row(
                                children: [
                                  IconButton(
                                      onPressed: () {
                                        Navigator.of(bContext).pop();
                                      },
                                      icon:
                                          const Icon(Icons.arrow_back_rounded)),
                                  Expanded(
                                    // this below Semantics does help to identify the element using element selection
                                    child: Semantics(
                                      identifier: 'From Semantics',
                                      container: true,
                                      child: const Text(
                                        'I should have the Semantics',
                                        // this does not let the element identified using element selection
                                        // semanticsIdentifier:
                                        //     'From Text Parameter',
                                      ),
                                    ),
                                  ),
                                  IconButton(
                                      onPressed: () {
                                        Navigator.of(bContext).pop();
                                      },
                                      icon: const Icon(Icons.close_rounded)),
                                ],
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                  );
                });
          },
          child: const Text('Click Here'),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
purvikrana@Purviks-MacBook-Pro dialog_text_semantics % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.7, on macOS 26.1 25B78 darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.4)
    ! CocoaPods 1.14.3 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.96.4)
[✓] Connected device (2 available)
    ! Error: Browsing on the local area network for Purvik Rana. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Purvik’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.
purvikrana@Purviks-MacBook-Pro dialog_text_semantics % 

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: typographyText rendering, possibly libtxtfound in release: 3.38Found to occur in 3.38found in release: 3.40Found to occur in 3.40frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions