Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView with PageStorageKey with TextField inside not keeping scroll position #62332

Open
n3o2k7i8ch5 opened this issue Jul 27, 2020 · 14 comments
Labels
a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@n3o2k7i8ch5
Copy link

n3o2k7i8ch5 commented Jul 27, 2020

Steps to Reproduce

The bug is occurs in the following code:

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text('PageStorageKey bug app'),
        ),
        drawer: Drawer(
          child: ListView(
            physics: BouncingScrollPhysics(),
            key: const PageStorageKey<String>('key_app_drawer'),
            children: <Widget>[

              Container(height: 400, width: 100, color: Colors.red),
              Container(height: 400, width: 100, color: Colors.blue),
              Container(height: 400, width: 100, color: Colors.red),
              Container(height: 400, width: 100, color: Colors.blue),
              Container(height: 400, width: 100, color: Colors.green),

              TextField()

            ],
          ),
        ),
        body: Container(),
      )
    );
  }
}

Expected results:

The scroll position of the listview should not change when opening and closing the drawer.

Actual results:

If the listview in the drawer contains a textfield, after two drawer opens it returns to its top position.

flutter_err

Logs
[  +11 ms] executing: [/home/dan/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +20 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 8af6b2f038c1172e61d418869363a28dffec3cb4
[        ] executing: [/home/dan/flutter/] git tag --contains HEAD
[ +142 ms] Exit code 0 from: git tag --contains HEAD
[   +1 ms] 1.17.5
[   +5 ms] executing: [/home/dan/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/home/dan/flutter/] git ls-remote --get-url origin
[   +3 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +48 ms] executing: [/home/dan/flutter/] git rev-parse --abbrev-ref HEAD
[   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +14 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[   +8 ms] executing: /home/dan/Android/Sdk/platform-tools/adb devices -l
[  +24 ms] List of devices attached
           emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:1
[  +11 ms] /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell getprop
[  +19 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +120 ms] Generating /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +16 ms] ro.hardware = ranchu
[  +18 ms] Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
[  +13 ms] Launching lib/main.dart on Android SDK built for x86 in debug mode...
[   +5 ms] /home/dan/flutter/bin/cache/dart-sdk/bin/dart /home/dan/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root /home/dan/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter
--debugger-module-names -Ddart.developer.causal_async_stacks=true --output-dill /tmp/flutter_tool.FUISXK/app.dill --packages /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/.packages -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root
[  +10 ms] executing: /home/dan/Android/Sdk/build-tools/30.0.0-rc4/aapt dump xmltree /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/build/app/outputs/apk/app.apk AndroidManifest.xml
[   +4 ms] Exit code 0 from: /home/dan/Android/Sdk/build-tools/30.0.0-rc4/aapt dump xmltree /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/build/app/outputs/apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.example.flutter_bug" (Raw: "com.example.flutter_bug")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="flutter_bug" (Raw: "flutter_bug")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.flutter_bug.MainActivity" (Raw: "com.example.flutter_bug.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=42)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=52)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=56)
                     E: action (line=57)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=59)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=66)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +5 ms] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -t 1
[  +11 ms] Exit code 0 from: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -t 1
[        ] --------- beginning of main
           07-27 14:23:12.413 E/PlayCommon( 2473): [131] apap.c(229): Failed to connect to server for log upload.
[   +9 ms] <- compile package:flutter_bug/main.dart
[   +7 ms] executing: /home/dan/Android/Sdk/platform-tools/adb version
[  +15 ms] Android Debug Bridge version 1.0.41
           Version 30.0.3-6597393
           Installed as /home/dan/Android/Sdk/platform-tools/adb
[   +1 ms] executing: /home/dan/Android/Sdk/platform-tools/adb start-server
[   +5 ms] Building APK
[  +12 ms] Running Gradle task 'assembleDebug'...
[   +1 ms] gradle.properties already sets `android.enableR8`
[   +1 ms] Using gradle from /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/android/gradlew.
[        ] /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/android/gradlew mode: 33277 rwxrwxr-x.
[   +5 ms] executing: /snap/android-studio/90/android-studio/jre/bin/java -version
[  +47 ms] Exit code 0 from: /snap/android-studio/90/android-studio/jre/bin/java -version
[        ] openjdk version "1.8.0_242-release"
           OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
           OpenJDK 64-Bit Server VM (build 25.242-b3-6222593, mixed mode)
[   +3 ms] executing: [/home/dan/MEGA/_Programy/_Kotlin/flutter_bug/android/] /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/android/gradlew -Pverbose=true -Ptarget-platform=android-x86 -Ptarget=/home/dan/MEGA/_Programy/_Kotlin/flutter_bug/lib/main.dart
-Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root assembleDebug
[ +602 ms] > Task :app:compileFlutterBuildDebug UP-TO-DATE
[        ] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
[        ] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preDebugBuild UP-TO-DATE
[        ] > Task :app:checkDebugManifest UP-TO-DATE
[        ] > Task :app:generateDebugBuildConfig UP-TO-DATE
[        ] > Task :app:cleanMergeDebugAssets
[        ] > Task :app:compileDebugAidl NO-SOURCE
[        ] > Task :app:compileDebugRenderscript NO-SOURCE
[        ] > Task :app:mergeDebugShaders UP-TO-DATE
[        ] > Task :app:compileDebugShaders UP-TO-DATE
[        ] > Task :app:generateDebugAssets UP-TO-DATE
[        ] > Task :app:mainApkListPersistenceDebug UP-TO-DATE
[        ] > Task :app:mergeDebugAssets
[ +181 ms] > Task :app:copyFlutterAssetsDebug
[        ] > Task :app:generateDebugResValues UP-TO-DATE
[        ] > Task :app:generateDebugResources UP-TO-DATE
[        ] > Task :app:mergeDebugResources UP-TO-DATE
[        ] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
[        ] > Task :app:processDebugManifest UP-TO-DATE
[        ] > Task :app:processDebugResources UP-TO-DATE
[        ] > Task :app:compileDebugKotlin UP-TO-DATE
[        ] > Task :app:javaPreCompileDebug UP-TO-DATE
[        ] > Task :app:compileDebugJavaWithJavac UP-TO-DATE
[        ] > Task :app:compileDebugSources UP-TO-DATE
[        ] > Task :app:processDebugJavaRes NO-SOURCE
[        ] > Task :app:mergeDebugJavaResource UP-TO-DATE
[        ] > Task :app:checkDebugDuplicateClasses UP-TO-DATE
[        ] > Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
[        ] > Task :app:validateSigningDebug UP-TO-DATE
[        ] > Task :app:desugarDebugFileDependencies UP-TO-DATE
[        ] > Task :app:mergeExtDexDebug UP-TO-DATE
[        ] > Task :app:mergeDexDebug UP-TO-DATE
[        ] > Task :app:signingConfigWriterDebug UP-TO-DATE
[        ] > Task :app:mergeDebugJniLibFolders UP-TO-DATE
[  +95 ms] > Task :app:mergeDebugNativeLibs UP-TO-DATE
[        ] > Task :app:stripDebugDebugSymbols UP-TO-DATE
[        ] Compatible side by side NDK version was not found.
[        ] > Task :app:packageDebug UP-TO-DATE
[  +35 ms] > Task :app:assembleDebug
[        ] BUILD SUCCESSFUL in 862ms
[        ] 31 actionable tasks: 4 executed, 27 up-to-date
[ +329 ms] Running Gradle task 'assembleDebug'... (completed in 1,3s)
[  +93 ms] calculateSha: LocalDirectory: '/home/dan/MEGA/_Programy/_Kotlin/flutter_bug/build/app/outputs/apk'/app.apk
[  +34 ms] calculateSha: reading file took 33us
[ +461 ms] calculateSha: computing sha took 461us
[   +2 ms] ✓ Built build/app/outputs/apk/debug/app-debug.apk.
[   +2 ms] executing: /home/dan/Android/Sdk/build-tools/30.0.0-rc4/aapt dump xmltree /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/build/app/outputs/apk/app.apk AndroidManifest.xml
[   +5 ms] Exit code 0 from: /home/dan/Android/Sdk/build-tools/30.0.0-rc4/aapt dump xmltree /home/dan/MEGA/_Programy/_Kotlin/flutter_bug/build/app/outputs/apk/app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.example.flutter_bug" (Raw: "com.example.flutter_bug")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="flutter_bug" (Raw: "flutter_bug")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.flutter_bug.MainActivity" (Raw: "com.example.flutter_bug.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=42)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=52)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=56)
                     E: action (line=57)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=59)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=66)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[        ] Stopping app 'app.apk' on Android SDK built for x86.
[        ] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell am force-stop com.example.flutter_bug
[  +23 ms] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell pm list packages com.example.flutter_bug
[ +190 ms] package:com.example.flutter_bug
[   +1 ms] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell cat /data/local/tmp/sky.com.example.flutter_bug.sha1
[  +11 ms] 66c3a2468883735d6ac5ff6c08f99afbdadeb444
[        ] Latest build already installed.
[        ] Android SDK built for x86 startApp
[   +1 ms] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points
true com.example.flutter_bug/com.example.flutter_bug.MainActivity
[  +20 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.flutter_bug/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[ +365 ms] Observatory URL on device: http://127.0.0.1:57116/vLotOAI6K8Q=/
[   +1 ms] executing: /home/dan/Android/Sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:57116
[   +6 ms] 33819
[        ] Forwarded host port 33819 to device port 57116 for Observatory
[+2074 ms] Connecting to service protocol: http://127.0.0.1:33819/vLotOAI6K8Q=/
[ +107 ms] Successfully connected to service protocol: http://127.0.0.1:33819/vLotOAI6K8Q=/
[   +2 ms] Sending to VM service: getVM({})
[   +3 ms] Result: {type: VM, name: vm, architectureBits: 32, hostCPU: Android 32-bit virtual processor, operatingSystem: android, targetCPU: ia32, version: 2.8.4 (stable) (Wed Jun 3 12:26:04 2020 +0200) on "android_ia32", _profilerMode: VM, _nativeZoneMemoryUsage:
...
[   +3 ms] Sending to VM service: getIsolate({isolateId: isolates/854970111559179})
[   +2 ms] Sending to VM service: _flutter.listViews({})
[  +14 ms] Result: {type: Isolate, id: isolates/854970111559179, name: main, number: 854970111559179, _originNumber: 854970111559179, startTime: 1595852595005, _heaps: {new: {type: HeapSpace, name: new, vmName: Scavenger, collections: 4, avgCollectionPeriodMillis:
6...
[   +8 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xa363d390, isolate: {type: @Isolate, fixedId: true, id: isolates/854970111559179, name: main.dart$main-854970111559179, number: 854970111559179}}]}
[   +4 ms] DevFS: Creating new filesystem on the device (null)
[        ] Sending to VM service: _createDevFS({fsName: flutter_bug})
[  +12 ms] Result: {type: FileSystem, name: flutter_bug, uri: file:///data/user/0/com.example.flutter_bug/code_cache/flutter_bugGJPBEZ/flutter_bug/}
[        ] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.flutter_bug/code_cache/flutter_bugGJPBEZ/flutter_bug/)
[   +1 ms] Updating assets
[  +50 ms] Syncing files to device Android SDK built for x86...
[   +1 ms] Scanning asset files
[   +2 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[        ] <- recompile package:flutter_bug/main.dart e85b47af-1456-4e3a-a59e-95ab24355a73
[        ] <- e85b47af-1456-4e3a-a59e-95ab24355a73
[  +73 ms] Updating files
[  +79 ms] DevFS: Sync finished
[        ] Syncing files to device Android SDK built for x86... (completed in 156ms)
[        ] Synced 0.9MB.
[        ] Sending to VM service: _flutter.listViews({})
[   +1 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0xa363d390, isolate: {type: @Isolate, fixedId: true, id: isolates/854970111559179, name: main.dart$main-854970111559179, number: 854970111559179}}]}
[        ] <- accept
[        ] Connected to _flutterView/0xa363d390.
[        ] Flutter run key commands.
[        ] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h Repeat this help message.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:33819/vLotOAI6K8Q=/


Analyzing flutter_bug...                                                
No issues found! (ran in 2.2s)
[✓] Flutter (Channel stable, v1.17.5, on Linux, locale pl_PL.UTF-8)
    • Flutter version 1.17.5 at /home/dan/flutter
    • Framework revision 8af6b2f038 (4 weeks ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
    • Android SDK at /home/dan/Android/Sdk
    • Platform android-30, build-tools 30.0.0-rc4
    • ANDROID_HOME = /home/dan/Android/Sdk
    • Java binary at: /snap/android-studio/90/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    ✗ Android license status unknown.
      Try re-installing or updating your Android SDK Manager.
      See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions.

[✓] Android Studio (version 4.0)
    • Android Studio at /snap/android-studio/90/android-studio
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

! Doctor found issues in 1 category.
@pedromassangocode
Copy link

pedromassangocode commented Jul 27, 2020

Hi @n3o2k7i8ch5
I can't reproduce this on dev nor stable channel.

Did you tried to reproduce this on a different device?

Flutter doctor -v (dev)
[✓] Flutter (Channel dev, 1.21.0-1.0.pre, on Mac OS X 10.15.5 19F101, locale
    en-AO)
    • Flutter version 1.21.0-1.0.pre at /Users/pedro/dev/SDKs/flutter_dev
    • Framework revision f25bd9c55c (13 days ago), 2020-07-14 20:26:01 -0400
    • Engine revision 99c2b3a245
    • Dart version 2.9.0 (build 2.9.0-21.0.dev 20bf2fcf56)
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/pedro/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Users/pedro/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6514223/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/pedro/Library/Application
      Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6514223/Android
      Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.47.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.1

[✓] Connected device (4 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9
      (API 28) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • Mac OS X
      10.15.5 19F101
    • Web Server (web)             • web-server    • web-javascript • Flutter
      Tools
    • Chrome (web)                 • chrome        • web-javascript • Google
      Chrome 84.0.4147.89

• No issues found!
flutter doctor -v (stable)
[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale en-AO)
    • Flutter version 1.17.5 at /Users/pedro/dev/SDKs/flutter_stable
    • Framework revision 8af6b2f038 (4 weeks ago), 2020-06-30 12:53:55 -0700
    • Engine revision ee76268252
    • Dart version 2.8.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at /Users/pedro/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: /Users/pedro/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6514223/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/pedro/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6514223/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.47.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.1

[✓] Connected device (1 available)
    • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)

• No issues found!
Process finished with exit code 0

@pedromassangocode pedromassangocode added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jul 27, 2020
@n3o2k7i8ch5
Copy link
Author

Hi,
Yes, I tried it on:

  • Xiaomi Redmi Note 5,
  • LG G2,
  • Android API 27 Emulator,
  • Android API 28 Emulator.

The issue persists on all devices.

I just tried it on stable, beta and dev, no difference.

I think it suggests that this could be related to the particular installation of flutter on my computer, but at this point I have not idea what to look for. Unfortunately I have no other computer to install flutter on.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 27, 2020
@n3o2k7i8ch5
Copy link
Author

I notices however, that on a physical phone it sometimes takes more "open/close" actions to reset the scroll position.

@pedromassangocode
Copy link

pedromassangocode commented Jul 28, 2020

I was able to reproduce on dev and stable channel, the issue only happens with the following steps:

  1. Open the drawer
  2. Scroll down
  3. Close the drawer
  4. Open the drawer (don't scroll the content)
  5. Close the drawer
  6. Open the drawer and notice that the scroll position was reset.

The issue only happens if there is a TextField at the end of the drawer.

Tested on Android Emulator API 28.

@pedromassangocode pedromassangocode added f: scrolling Viewports, list views, slivers, etc. found in release: 1.17 Found to occur in 1.17 found in release: 1.21 Found to occur in 1.21 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on a: text input Entering text in a text field or keyboard related problems and removed in triage Presently being triaged by the triage team labels Jul 28, 2020
@HansMuller HansMuller added the f: material design flutter/packages/flutter/material repository. label Jul 28, 2020
@HansMuller HansMuller changed the title ListView with PageStorageKey with TexiField inside not keeping scroll position ListView with PageStorageKey with TextField inside not keeping scroll position Jul 28, 2020
@xu-baolin
Copy link
Member

I am currently investigating this issue.

@xu-baolin
Copy link
Member

@n3o2k7i8ch5 This issue because TextField also has a Scrollable widget inside, so you need to give the TextField a PageStorageKey to avoid mutual influence. I modify your code like this, and it works perfectly.

import 'package:flutter/material.dart';

void main() {
  runApp(MyHomePage());
}

class MyHomePage extends StatefulWidget {

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  PageStorageKey key = PageStorageKey<String>('key_app_drawer');
  PageStorageKey key1 = PageStorageKey<String>('key_app_text');
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        home: Scaffold(
          appBar: AppBar(
            title: Text('PageStorageKey bug app'),
          ),
          drawer: Drawer(
//            key: key,
            child: ListView(
              key: key,
              children: <Widget>[
                Container(height: 700, width: 100, color: Colors.red),
                TextField(key: key1,)
              ],
            ),
          ),
          body: Container(),
        ));

  }
}

@n3o2k7i8ch5
Copy link
Author

@xu-baolin this indeed solves the problem.
I'm not sure whether this should be Flutter's normal behavior?

@xu-baolin
Copy link
Member

@xu-baolin this indeed solves the problem.
I'm not sure whether this should be Flutter's normal behavior?

I will double check it.

xu-baolin added a commit to xu-baolin/flutter that referenced this issue Aug 13, 2020
@gabrielgarciagava
Copy link
Contributor

gabrielgarciagava commented Aug 13, 2020

I also faced this issue, and found the same workaround that @xu-baolin did.
I don't think this is the expected behavior by flutter. I cannot imagine anyone that would like to have this effect on their code.

@SebastienBtr
Copy link

I'm facing a similar issue when using PageStorageKey, It seems to keep the scroll position only one time in two. My view is pretty complex, I can try to add keys everywhere but it's really annoying

@xu-baolin
Copy link
Member

@gabrielgarciagava @SebastienBtr Hi you guys,
I will make some changes to improve this situation and make it more developer-friendly.

xu-baolin added a commit to xu-baolin/flutter that referenced this issue Sep 25, 2020
@n3o2k7i8ch5
Copy link
Author

The issue still persists in flutter 3.3.1.
Adding PageStorageKey to the TextField resolves the issue, but it's extremely unintuitive (I managed to fix this issue in another place only because I stumbled upon my own github issue).

@maheshmnj
Copy link
Member

I am able to reproduce the issue

Screen.Recording.2023-01-02.at.9.05.06.PM.mov

Provided that this is working as intended as per #62332 (comment)

@xu-baolin do you think this needs further improvements and should be kept open?

code sample
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: Scaffold(
          appBar: AppBar(
            title: Text('PageStorageKey bug app'),
          ),
          drawer: Drawer(
            child: ListView(
              physics: BouncingScrollPhysics(),
              key: const PageStorageKey<String>('key_app_drawer'),
              children: <Widget>[
                Container(height: 400, width: 100, color: Colors.red),
                Container(height: 400, width: 100, color: Colors.blue),
                Container(height: 400, width: 100, color: Colors.red),
                Container(height: 400, width: 100, color: Colors.blue),
                Container(height: 400, width: 100, color: Colors.green),
                TextField()
              ],
            ),
          ),
          body: Container(),
        ));
  }
}
flutter doctor -v (mac)
[✓] Flutter (Channel master, 3.7.0-13.0.pre.131, on macOS 13.1 22C65 darwin-arm64, locale en-IN)
    • Flutter version 3.7.0-13.0.pre.131 on channel master at /Users/mahesh/Development/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 0196e6050b (2 days ago), 2022-12-31 11:10:23 -0500
    • Engine revision 932591ec04
    • Dart version 3.0.0 (build 3.0.0-76.0.dev)
    • DevTools version 2.20.0
    • 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-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.74.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.56.0

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.1 22C65 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.124

[✓] HTTP Host Availability
    • All required HTTP hosts are available
    
• No issues found!
[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
    • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • 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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.70.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.53.20221101

[✓] Connected device (3 available)
    • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@maheshmnj maheshmnj removed the found in release: 1.17 Found to occur in 1.17 label Jan 3, 2023
@maheshmnj maheshmnj added found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 and removed found in release: 1.21 Found to occur in 1.21 labels Jan 3, 2023
@Piinks Piinks added the P2 Important issues not at the top of the work list label Mar 21, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@meowofficial
Copy link

Related #53040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. found in release: 3.3 Found to occur in 3.3 found in release: 3.7 Found to occur in 3.7 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants