Repository: flutter
Issue: [A11Y] Toggleable widgets get out of sync with ScreenReaders
Labels: framework,f: material design,a: accessibility,has reproducible steps,P2,found in release: 3.10,found in release: 3.12,team-design,triaged-design

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

When interacting with a Switch/Checkbox with ScreenReaders and when there is a delay to update the state, ScreenReaders always announcing the old state instead of new one.

1. Get the [Sample Code](https://github.com/838/fluttemo/tree/a11y/togglabl)
2. Run the app on a read device
3. Enable VO or Talkback 
4. Navigate to a Switch or Checkbox with ❌ label
5. Double tap on the widget
6. Note that ScreenReader announces the old state.

### Expected results

ScreenReaders should announce the correct state of the Switch/Checkbox widget.

### Actual results

ScreenReaders announcing the incorrect state.

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:rxdart/subjects.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      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> {
  final state = BehaviorSubject.seeded(true);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            _buildSwitch('✅'),
            _buildSwitch('❌'),
            _buildCheckbox('✅'),
            _buildCheckbox('❌'),
          ],
        ),
      ),
    );
  }

  Row _buildSwitch(
    String text,
  ) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        ExcludeSemantics(child: Text(text)),
        StreamBuilder(
          stream: state,
          initialData: state.value,
          builder: (
            BuildContext context,
            AsyncSnapshot snapshot,
          ) {
            return Switch(
              value: snapshot.data,
              onChanged: (val) async {
                if (text == '❌') {
                  await Future.delayed(const Duration(milliseconds: 200));
                }
                state.value = val;
              },
            );
          },
        ),
      ],
    );
  }

  Row _buildCheckbox(
    String text,
  ) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        ExcludeSemantics(child: Text(text)),
        StreamBuilder(
          stream: state,
          initialData: state.value,
          builder: (
            BuildContext context,
            AsyncSnapshot snapshot,
          ) {
            return Checkbox(
              value: snapshot.data,
              onChanged: (val) async {
                if (text == '❌') {
                  await Future.delayed(const Duration(milliseconds: 200));
                }

                state.value = val ?? true;
              },
            );
          },
        ),
      ],
    );
  }
}

```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/3314171/091fb54a-f428-4dee-ae0d-39c032ed7bbc

https://github.com/flutter/flutter/assets/3314171/8f489205-50ef-403f-9508-3df26ae65892

</details>


### Logs

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


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.10.4, on macOS 13.4 22F66 darwin-x64, locale en-GB)
    • Flutter version 3.10.4 on channel stable at /Users/b044560/Developments/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (4 days ago), 2023-06-05 18:04:56 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/b044560/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /Users/b044560/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • 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.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • 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 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.67.20230601

[✓] Connected device (4 available)            
    • DN2103 (mobile) • 5HEU55Q45TQKVKIZ          • android-arm64  • Android 12 (API 31)
    • iPhone (mobile) • 00008030-001470DE010A802E • ios            • iOS 16.2 20C65
    • macOS (desktop) • macos                     • darwin-x64     • macOS 13.4 22F66 darwin-x64
    • Chrome (web)    • chrome                    • web-javascript • Google Chrome 114.0.5735.106

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>