Repository: flutter
Issue: Input always move the cursor at end of text selection
Labels: a: text input,platform-android,framework,f: material design,has reproducible steps,P2,found in release: 3.16,found in release: 3.20,team-text-input

### Steps to reproduce

1. Create a new project with basic template with `flutter create input_test`.
2. Paste the code below at `Code sample` section.

3. Scroll to the end of page, select any word and try to move the select cursor over the text above looks like on the video attached.

### Expected results

1. When selection moves the scroll position in reverse mode (moving to top on this case) the cursor should be placed on the first character of selection, avoiding this strange scroll flick.
2. Otherwise, the cursor must be placed at the last character of selection (seems correct in this case).

### Actual results

When selection moves the scroll position in reverse mode (moving to top on this case) the cursor always retorn to the last character of input, causing a strange scroll, especially when the distance between the start and end of selection is very large or has reached the top

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

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.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final controller = TextEditingController(
    text:
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In convallis risus mauris, id cursus nisl congue a. Integer auctor, dui a viverra vehicula, felis enim luctus lectus, at consectetur purus justo vel risus. Pellentesque lacinia nisi nunc, nec suscipit nisl tempor consequat. In vulputate, nunc quis fermentum consectetur, neque neque ultrices nunc, et aliquet turpis turpis non leo. Phasellus cursus magna ac enim congue bibendum. Nunc nec aliquet ipsum, ut lacinia velit. Nullam eros dui, convallis in tellus vulputate, finibus ultrices lacus. Quisque elementum interdum dui, in tincidunt sem tempor sed. Quisque condimentum, nunc in lobortis placerat, purus est convallis ex, quis dignissim diam leo sit amet ipsum. In mattis id dui ut molestie. Aliquam erat volutpat. Fusce sed odio massa. Pellentesque laoreet iaculis elit non eleifend. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In convallis risus mauris, id cursus nisl congue a. Integer auctor, dui a viverra vehicula, felis enim luctus lectus, at consectetur purus justo vel risus. Pellentesque lacinia nisi nunc, nec suscipit nisl tempor consequat. In vulputate, nunc quis fermentum consectetur, neque neque ultrices nunc, et aliquet turpis turpis non leo. Phasellus cursus magna ac enim congue bibendum. Nunc nec aliquet ipsum, ut lacinia velit. Nullam eros dui, convallis in tellus vulputate, finibus ultrices lacus. Quisque elementum interdum dui, in tincidunt sem tempor sed. Quisque condimentum, nunc in lobortis placerat, purus est convallis ex, quis dignissim diam leo sit amet ipsum. In mattis id dui ut molestie. Aliquam erat volutpat. Fusce sed odio massa. Pellentesque laoreet iaculis elit non eleifend.",
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.symmetric(
            vertical: 8,
            horizontal: 12,
          ),
          child: TextField(
            controller: controller,
            maxLines: null,
            style: const TextStyle(color: Colors.black, fontSize: 24),
          ),
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/77847606/704d9131-594d-444b-b7ec-25fd65bb8d19

</details>


### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[√] Flutter (Channel master, 3.20.0-4.0.pre.48, on Microsoft Windows [versÆo 10.0.22621.3007], locale pt-BR)
    • Flutter version 3.20.0-4.0.pre.48 on channel master at C:\Flutter
    • Upstream repository https://github.com/flutter/flutter
    • Framework revision fbc9f2d5bf (6 days ago), 2024-02-08 12:39:00 -0800
    • Engine revision fb99a84de0
    • Dart version 3.4.0 (build 3.4.0-116.0.dev)
    • DevTools version 2.32.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Users\vinic\AppData\Local\Android\Sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = C:\Users\vinic\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-b2043.56-10550314)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.7.34031.279
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.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 17.0.7+0-b2043.56-10550314)

[√] VS Code (version 1.86.1)
    • VS Code at C:\Users\vinic\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.82.0

[√] Connected device (4 available)
    • SM G780G (mobile) • 192.168.3.7:5555 • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [versÆo 10.0.22621.3007]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 121.0.6167.161
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 121.0.2277.106

[√] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>