Repository: flutter
Issue: Giving focus to a text field ignores a Scaffold bottomSheet, leading to the text field not being visible
Labels: framework,f: scrolling,f: focus,has reproducible steps,P2,found in release: 3.7,found in release: 3.9,team-framework,triaged-framework

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Execute `flutter run` on the code sample <!-- (see "Code sample" section below) -->
2. Use the "Next" Text Button to traverse the TextFields until the point where the scroll view is scrolled to make the next TextField visible due to the on screen keyboard hiding the next TextField. This usually happens around the 10th field.

**Expected results:** 
The bottomSheet is taken to account, and the view is scrolled so the TextField is just above the bottomSheet, meaning it is visible when focused.

**Actual results:**
The view is scrolled so the text field is above the keyboard, but below the bottomSheet, meaning it is not visible.

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

```import 'package:flutter/material.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(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomSheet: Container(
        height: 50,
        width: double.infinity,
        color: Colors.black,
        child: Focus(
          descendantsAreFocusable: false,
          canRequestFocus: false,
          child: TextButton(
            onPressed: () {
              FocusScope.of(context).nextFocus();
            },
            child: Text("Next"),
          ),
        ),
      ),
      body: ListView(
        children: [
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
          TextField(),
        ],
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

```
[ +135 ms] com.example.testFocusNode: 30738
[        ] Waiting for observatory port to be available...
[ +448 ms] Observatory URL on device: http://127.0.0.1:49718/PkJD9dX7ZOk=/
[   +4 ms] Caching compiled dill
[  +56 ms] Connecting to service protocol: http://127.0.0.1:49718/PkJD9dX7ZOk=/
[  +73 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:49718/PkJD9dX7ZOk=/.
[  +38 ms] DDS is listening at http://127.0.0.1:49721/FtEjUbnP4ME=/.
[  +32 ms] Successfully connected to service protocol: http://127.0.0.1:49718/PkJD9dX7ZOk=/
[  +17 ms] DevFS: Creating new filesystem on the device (null)
[  +10 ms] DevFS: Created new filesystem on the device (file:///Users/jacobscase/Library/Developer/CoreSimulator/Devices/B66C37DF-F54E-4324-A378-110B648F74C3/data/Containers/Data/Application/CA0C7DA0-8681-40AD-8850-C9564D0D870E/tmp/test_focus_node9Hii21/test_focus_node/)
[   +1 ms] Updating assets
Debug service listening on ws://127.0.0.1:49721/FtEjUbnP4ME=/ws
Syncing files to device iPhone 14 Pro...
[  +84 ms] Compiling dart to kernel with 0 updated files
[        ] Processing bundle.
[        ] <- recompile package:test_focus_node/main.dart 76869175-1558-456f-a4dc-9930edbe551e
[        ] <- 76869175-1558-456f-a4dc-9930edbe551e
[        ] Bundle processing done.
[  +59 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Synced 0.0MB.
[        ] <- accept
[   +1 ms] Connected to _flutterView/0x12b00cc20.
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
 % flutter analyze
Analyzing test_focus_node...                                            
No issues found! (ran in 0.9s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[!] Flutter (Channel stable, 3.7.8, on macOS 13.2.1 22D68 darwin-arm64, locale en-GB)
    • Flutter version 3.7.8 on channel stable at /Users/jacobscase/flutter
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.19.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at
      /Users/jacobscase/flutter. Consider adding /Users/jacobscase/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 90c64ed42b (7 days ago), 2023-03-21 11:27:08 -0500
    • Engine revision 9aa7816315
    • Dart version 2.19.5
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jacobscase/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Users/jacobscase/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9514443/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.15+0-b2043.56-8887301)

[✓] Android Studio (version 2022.1)
    • Android Studio at /Users/jacobscase/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/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.15+0-b2043.56-8887301)

[✓] VS Code (version 1.76.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (4 available)
    • SM G780F (mobile)      • RF8N932JNCY                          • android-arm64  • Android 13 (API 33)
    • iPhone 14 Pro (mobile) • B66C37DF-F54E-4324-A378-110B648F74C3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 111.0.5563.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.

```

</details>


https://user-images.githubusercontent.com/25490095/228239911-35a58176-4ecb-4bfc-b59a-a4293d8b699a.mp4


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->