Repository: flutter
Issue: resource-id not working correctly inside Card
Labels: platform-android,framework,f: material design,a: accessibility,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.19,found in release: 3.22

### Steps to reproduce

1. Create a `Card`
2. Create multiple elements inside the `Card` with different `Semantics.identifier` on each one
3. Build app
4. Analyze the UI using appium-inspector or similar

### Expected results

Elements inside the `Card` should be discerned and separated with their respective `Semantics.identifier`, as that was implemented on https://github.com/flutter/engine/pull/47961

If a `Container` is used instead of the `Card`, the results are what should be expected (see last screenshot)

### Actual results

`Card` shows as a Button in the inspector, with only the top-most `Semantics.identifier` showing.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

final List<DropdownMenuItem<String>> items = <DropdownMenuItem<String>>[
  const DropdownMenuItem<String>(value: 'One', child: Text('One')),
  const DropdownMenuItem<String>(value: 'Two', child: Text('Two')),
  const DropdownMenuItem<String>(value: 'Three', child: Text('Three')),
];

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.blue),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  DropdownMenuItem<String> selectedItem = items.first;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Card(
              child: Padding(
                  padding: const EdgeInsets.all(16),
                  child: Column(
                    children: [
                      Semantics(
                        identifier: 'dropdown_test',
                        child: const Text(
                          'Dropdown Test',
                          style: TextStyle(fontSize: 20),
                        ),
                      ),
                      Semantics(
                        identifier: 'dropdown',
                        child: DropdownButton(
                            items: items,
                            value: selectedItem.value,
                            onChanged: (String? s) {
                              setState(() {
                                selectedItem = items.firstWhere(
                                    (element) => element.value == s);
                              });
                            }),
                      ),
                    ],
                  )),
            ),
          ],
        ),
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

Using `Card` as the widget, only `dropdown_test` shows up in `resource-id`: 
<img width="1473" alt="Screenshot 2024-04-03 at 11 14 32 AM" src="https://github.com/flutter/flutter/assets/11811569/0db0f729-36c9-44b9-b3e5-3960d57ded69">

Using `Container`, both `resource-id` show up:
<img width="1473" alt="Screenshot 2024-04-03 at 11 15 00 AM" src="https://github.com/flutter/flutter/assets/11811569/f2e43471-a7c9-464d-a187-4d1896a39c67">

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.1.1 23B81 darwin-arm64, locale en-CA)
    • Flutter version 3.19.4 on channel stable at /Users/juanmanjarres/fvm/versions/3.19.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 68bfaea224 (2 weeks ago), 2024-03-20 15:36:31 -0700
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/juanmanjarres/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/juanmanjarres/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C65
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.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.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Community Edition (version 2023.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.86.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 14 (API 34) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 123.0.6312.87

[✓] Network resources
    • All expected network resources are available.

• No issues found!

```

</details>