Repository: flutter
Issue: ModalRoute cannot be dismissed by tap outside the modal when screen reader is turned on
Labels: platform-android,platform-ios,framework,a: accessibility,has reproducible steps,P2,found in release: 3.7,found in release: 3.10,team-framework,triaged-framework

### 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)

### Use case

We have a task that requires pushing `PopupRoute` into the `Navigator`, but we have encountered unexpected behavior of `ModalBarrier` widget, which is opened by `PopupRoute`, on Android devices.

Considering that `barrierSemanticsDismissible` of `ModalBarrier` will be set to **true**, due to an internal check on `platformSupportsDismissingBarrier`, it turns out that for Android devices it is impossible to close the modal window by tapping outside the window with accessibility enabled.
So `barrierSemanticsDismissible` in `ModalBarrier` does nothing on Android devices.

Even though there is a comment inside `ModalBarrier` that says 

> On Android, the back button is used to dismiss a modal

We expect users with screen reader enabled to be able to dismiss modal windows by tapping outside the windows themselves.

Steps to reproduce:
1. Download a screen reader if you don't have one. For example, TalkBack.
2. Enable screen reader on a device (Settings → Accessibility).
3. Launch Flutter application (sample code below).
4. Open a dialog with some accessibility-focusable content (in the example, I've putted FloatingActionButton to open the dialog).
5. Tap on the content inside the dialog to focus the screen reader on the dialog content.
6. Try to close the dialog by tapping outside the dialog area.

<details>
  <summary>Video</summary>

https://user-images.githubusercontent.com/23009512/233980104-368dfc69-7fe7-4030-842e-f10bf65fff1b.mp4
</details>

<details>
  <summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const AccessibilityDismissApp());
}

class AccessibilityDismissApp extends StatelessWidget {
  const AccessibilityDismissApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        floatingActionButton: Builder(
          builder: (context) {
            return FloatingActionButton(
              onPressed: () {
                Navigator.of(context, rootNavigator: true).push(
                  RawDialogRoute<void>(
                    barrierDismissible: true,
                    pageBuilder: (context, _, __) => const Center(
                      child: DialogContent(),
                    ),
                  ),
                );
              },
              child: const Icon(Icons.open_in_new),
            );
          },
        ),
      ),
    );
  }
}

class DialogContent extends StatefulWidget {
  const DialogContent({super.key});

  @override
  State<DialogContent> createState() => _DialogContentState();
}

class _DialogContentState extends State<DialogContent> {
  var _switchValue = true;

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Switch(
        onChanged: (value) {
          setState(() {
            _switchValue = value;
          });
        },
        value: _switchValue,
      ),
    );
  }
}
```
</details>

<details>
  <summary>Flutter doctor</summary>

[!] Flutter (Channel unknown, 3.3.10, on Microsoft Windows [Version 10.0.19045.2846], locale en-US)
    ! Flutter version 3.3.10 on channel unknown at C:\src\flutter
    ! Upstream repository unknown
    • Framework revision 135454af32 (4 months ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\user\AppData\Local\Android\sdk
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.4.33213.308
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.15+0-b2043.56-8887301)

[√] VS Code (version 1.77.3)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.62.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.2846]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 112.0.5615.138
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 112.0.1722.48

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
</details>

### Proposal

Make `barrierSemanticsDismissible` in `ModalBarrier` relevant for Android devices. Or at least to make it possible to dismiss `ModalBarrier` with enabled screen reader.

One of suggestions: get rid of `platformSupportsDismissingBarrier` and leave only `barrierSemanticsDismissible` to solve dismiss possibility.

<details>
  <summary>Rough code proposal for ModalBarrier build method</summary>

```dart
  @override
  Widget build(BuildContext context) {
    assert(!dismissible || semanticsLabel == null || debugCheckHasDirectionality(context));
    final modalBarrierSemanticsDismissible = barrierSemanticsDismissible ?? dismissible;

    void handleDismiss() {
      if (dismissible) {
        if (onDismiss != null) {
          onDismiss!();
        } else {
          Navigator.maybePop(context);
        }
      } else {
        SystemSound.play(SystemSoundType.alert);
      }
    }

    return BlockSemantics(
      child: ExcludeSemantics(
        excluding: !dismissible || !modalBarrierSemanticsDismissible,
        child: _ModalBarrierGestureDetector(
          onDismiss: handleDismiss,
          child: Semantics(
            label: dismissible ? semanticsLabel : null,
            onDismiss: dismissible ? handleDismiss : null,
            textDirection:
                dismissible && semanticsLabel != null ? Directionality.of(context) : null,
            child: MouseRegion(
              cursor: SystemMouseCursors.basic,
              child: ConstrainedBox(
                constraints: const BoxConstraints.expand(),
                child: color == null
                    ? null
                    : ColoredBox(
                        color: color!,
                      ),
              ),
            ),
          ),
        ),
      ),
    );
  }
```
</details>