fluttercandies / extended_nested_scroll_view

extended nested scroll view to fix following issues. 1.pinned sliver header issue 2.inner scrollables in tabview sync issue 3.pull to refresh is not work. 4.do without ScrollController in NestedScrollView's body
MIT License
591 stars 117 forks source link

[Bug report] Request Focus TextFormField not Scroll Correctly #145

Closed sed1ka closed 9 months ago

sed1ka commented 9 months ago

Version

6.1.2

Platforms

Android, (untested on iOS)

Device Model

Xiaomi Redmi 9T

flutter info

[√] Flutter (Channel stable, 3.13.3, on Microsoft Windows [Version 10.0.19043.1766], locale en-US)
    • Flutter version 3.13.3 on channel stable at D:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2524052335 (7 days ago), 2023-09-06 14:32:31 -0700
    • Engine revision b8d35810e9
    • Dart version 3.1.1
    • DevTools version 2.25.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\septian.andika\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.5.2)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33502.453
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK

[√] Android Studio (version 2022.2)
    • 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.6+0-b2043.56-9586694)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19043.1766]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 116.0.5845.180
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 116.0.1938.69

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

How to reproduce?

Run my example code I provide

The Bug: When you tap/request to focus the TextField B the scroll will be reset to the top instead scrolling to the TextField B. The bug only happen if:

  1. The body in ExtendedNestedScrollView contains more than one TextFormField.
  2. The TextFormField is on bottom of view port. Make sure the TextFormField is covered by the keyboard screen when you press the TextFormField.

Example code (optional)

class ExampleView extends StatefulWidget {
  const ExampleView({super.key});

  @override
  State<KrediCashView> createState() => _ExampleViewState();
}

class _ExampleViewState extends State<ExampleView> {
  final FocusNode focusNodeA = FocusNode();
  final FocusNode focusNodeB = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ExtendedNestedScrollView(
        headerSliverBuilder: (_, __) {
          return [
            SliverAppBar(
              title: Text('Bug Focus Node'),
            ),
          ];
        },
        body: SingleChildScrollView(
          child: Column(
            children: [
              const SizedBox(height: 1000),
              TextFormField(
                focusNode: focusNodeA,
                decoration: InputDecoration(
                  labelText: 'TextField A',
                ),
              ),
              const SizedBox(height: 1000),
              TextFormField(
                focusNode: focusNodeB,
                decoration: InputDecoration(
                  labelText: 'TextField B',
                ),
              ),
              const SizedBox(height: 10),
            ],
          ),
        ),
      ),
    );
  }
}
zmtzawqlp commented 9 months ago

It's better to create an issue for Flutter team first.

sed1ka commented 9 months ago

The bug only happen with the ExtendedNestedScrollView. Using NestedScrollView with SingleChildScrollView will give result as expected.

It's better to create an issue for Flutter team first.

sed1ka commented 9 months ago

Mysteriously the bug doesn't happen anymore. Even though I haven't made any fix. So I will close the issue