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
Comments
Hi @n3o2k7i8ch5 Did you tried to reproduce this on a different device? Flutter doctor -v (dev)
flutter doctor -v (stable)
|
Hi,
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. |
I notices however, that on a physical phone it sometimes takes more "open/close" actions to reset the scroll position. |
I was able to reproduce on
The issue only happens if there is a TextField at the end of the drawer. Tested on Android Emulator API 28. |
I am currently investigating this issue. |
@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.
|
@xu-baolin this indeed solves the problem. |
I will double check it. |
I also faced this issue, and found the same workaround that @xu-baolin did. |
I'm facing a similar issue when using |
@gabrielgarciagava @SebastienBtr Hi you guys, |
The issue still persists in flutter 3.3.1. |
I am able to reproduce the issue Screen.Recording.2023-01-02.at.9.05.06.PM.movProvided 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 sampleimport '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)
|
Related #53040 |
Steps to Reproduce
The bug is occurs in the following code:
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.
Logs
The text was updated successfully, but these errors were encountered: