Repository: flutter
Issue: Accessibility Focus jumps to Scaffold's AppBar while trying to swipe down or up in a listview
Labels: framework,f: material design,a: accessibility,a: quality,customer: crowd,has reproducible steps,P2,found in release: 2.10,found in release: 2.11,team-accessibility,triaged-accessibility

## General info

The issue is observed in Flutter versions 2.5.3 and 2.8.1.
The issue manifests a bit differently on Android and iOS.
The issue is observed on all iOS versions 15.x, up to the current 15.3.1. I could not test the issue on previous versions due to lack of devices.
This issue is observed on Android version 12. On Android 10, the behaviour is more or less as expected.

## Steps to Reproduce

1. Create a new Flutter app with `flutter create` and paste the Code sample provided below in the `main.dart` file
2. Run a project on a real device
3. On iOS: Turn on a VoiceOver accessibility feature (if not already configured, VoiceOver can be turned on via a shortcut. To configure, go to Settings -> Accessibility -> Accessibility Shortcut)
OR
On Android: Turn on TalkBack (if not already configured, TalkBack can be turned on via a shortcut. To configure, go to Settings -> Accessibility -> TalkBack -> TalkBack Shortcut)
4. Select an element from the list with accessibility focus
5. Scroll the list with 3-fingers-swipe gesture on iOS or 2-fingers-swipe on Android
6. Observe what happens when the selected element moves out of the screen as you focus

NOTE: This issue is observed when scrolling upwards as well as downwards. It is also observed when using horizontal lists.

**Expected results:** 

The focus navigates to the next elements of the screen gracefully like in popular apps, e.g. YouTube app.
Please check the attached behaviour of native Youtube app on iPad for a clear example.
Alternatively, it at least stays focused on the list and does not jump to appBar widget abruptly.

**Actual results:**

On iOS, the focus jumps to Scaffold's AppBar as soon as it leaves the viewport of the screen.
On Android, the focus disappears completely. If the user chooses to move the focus to the next element via Swipe Right gesture, AppBar is selected.
Alternatively, some people reported a bit different behaviour for Android: the focus stays on the list element until it is moved away from the phone's screen, even if the list's viewport is much smaller (e.g. there's big padding around the list). I could not reproduce this behaviour myself, therefore I will not provide a specific Code sample with paddings. The bottom line is, a11y focus behaviour is inconsistent in lists on Android 12 platform.

<details>
<summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({
    Key? key,
  }) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final items = List<String>.generate(1000, (i) => 'Item $i');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Demo Home Page'),
      ),
      body: Center(
        child: ListView.builder(
          itemCount: items.length,
          itemBuilder: (context, index) {
            return ListTile(
              title: Text(items[index]),
            );
          },
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

Running the app with `flutter run --verbose` did not provide any non-trivial information.

Running `flutter analyze` yields
```
Analyzing myapp...                                              
No issues found! (ran in 0.8s)
```
`flutter doctor -v` output:

```
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.2 21D49 darwin-arm, locale en-GB)
    • Flutter version 2.5.3 at /Users/danya/fvm/versions/2.5.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (4 months ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/danya/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.2.1, Build version 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • 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.11+0-b60-7772763)

[✓] VS Code (version 1.64.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (3 available)
    • My iPad (mobile) • 00008020-0001386E3AA2402E • ios            • iOS 15.3.1 19D52
    • macOS (desktop)  • macos                     • darwin-arm64   • macOS 12.2 21D49 darwin-arm
    • Chrome (web)     • chrome                    • web-javascript • Google Chrome 98.0.4758.80

• No issues found!
```
</details>

<details>
  <summary>iPad Screenshots</summary>

![bug_1](https://user-images.githubusercontent.com/26414898/154246058-43c4828e-cf30-48ee-a604-b18bafea6c1e.jpg)
![bug_2](https://user-images.githubusercontent.com/26414898/154246061-98018d4b-3f7a-4fe5-97ca-8339b32fdeb9.jpg)

</details>

<details>
  <summary>iPad Youtube App Behavior</summary>

https://user-images.githubusercontent.com/26414898/154265213-b9d7c42b-b522-4f82-9ddf-2331534251aa.MP4

</details>