Skip to content

Conversation

goderbauer
Copy link
Member

Description

Enabled the TextField widgets (Material's TextField, CupertinoTextField) to restore their scroll offset and their text content with the state restoration framework.

This PR requires #63131 to land first.

Related Issues

#62916

Tests

I added the following tests:

  • Restoration tests for TextField and CupertinoTextField.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 10, 2020
@goderbauer goderbauer requested a review from justinmc August 10, 2020 17:29
@goderbauer
Copy link
Member Author

Tests will fail until #63131 is merged and this PR is rebased.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM besides a small naming typo in my comment below. I'm really excited for the ability to restore text fields, thanks for doing this!

I also wanted to make sure that you've thought about TextFormField as well. It just renders a TextField, so it should pick up all of the restoration logic here, but what about say its validation state? If a TextFormField is invalid and displaying an error, and then later it is restored, will it still be showing the validation error message? Maybe that's a separate issue.

}

Future<void> skipPastScrollingAnimation(WidgetTester tester) async {
await tester.pump();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this pump necessary even with the duration pump on the next line?

Same question for the material text field test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need one pump to start the animation. And another (with a duration) to finish it.

@@ -0,0 +1,125 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this file is missing an underscore, should be "text_field_restoration_test".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed.

@goderbauer
Copy link
Member Author

goderbauer commented Aug 10, 2020

I also wanted to make sure that you've thought about TextFormField as well.

I've not looked at that one yet, but added it to the backlog in #62916.

@goderbauer goderbauer merged commit 37ddad6 into flutter:master Aug 14, 2020
@goderbauer goderbauer deleted the restorableText branch August 14, 2020 19:02
smadey pushed a commit to smadey/flutter that referenced this pull request Aug 27, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants