Skip to content

Conversation

AlexV525
Copy link
Member

Description

Further work for #68086 . Deprecate maxLengthEnforced for text fields, and some nit picking update.

Tests

I added the following tests:

  • LengthLimitingTextInputFormatter get enforcement from target platform for text formatter test.

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.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change.

@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 Dec 10, 2020
@google-cla google-cla bot added the cla: yes label Dec 10, 2020
@AlexV525
Copy link
Member Author

Hmm, the commit seems not rolled in yet. Any ideas?

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

The PR looks good to me. Thank you for your patience and the effort put into the series of pull requests!

@@ -805,7 +820,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
FocusNode get _effectiveFocusNode => widget.focusNode ?? (_focusNode ??= FocusNode());

MaxLengthEnforcement get _effectiveMaxLengthEnforcement => widget.maxLengthEnforcement
?? LengthLimitingTextInputFormatter.inferredDefaultMaxLengthEnforcement;
?? LengthLimitingTextInputFormatter.getDefaultMaxLengthEnforcement();
Copy link
Contributor

Choose a reason for hiding this comment

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

like the new name 👍

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 related to the deprecation at all or just an improvement?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's an improvement, that the style guide say we preferred getXXX for method.

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, just one nit about an optional parameter.

I see that you updated the gallery (flutter/gallery#358) but it's still failing here. I'm not sure what needs to happen for the tests to get updated here...

@@ -432,11 +433,13 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
/// [MaxLengthEnforcement.truncateAfterCompositionEnds]. These platforms
/// allow the composition to exceed by default.
/// {@endtemplate}
static MaxLengthEnforcement get inferredDefaultMaxLengthEnforcement {
static MaxLengthEnforcement getDefaultMaxLengthEnforcement({
TargetPlatform? platform,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be better as an optional parameter with a default value instead?

  [TargetPlatform platform = defaultTargetPlatform],

Copy link
Member Author

Choose a reason for hiding this comment

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

If I remember it correctly, defaultTargetPlatform is a getter, so it cannot be the default value for arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

A position optional param or a named optional param both SGTM, I'll take your suggestion.

@@ -805,7 +820,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
FocusNode get _effectiveFocusNode => widget.focusNode ?? (_focusNode ??= FocusNode());

MaxLengthEnforcement get _effectiveMaxLengthEnforcement => widget.maxLengthEnforcement
?? LengthLimitingTextInputFormatter.inferredDefaultMaxLengthEnforcement;
?? LengthLimitingTextInputFormatter.getDefaultMaxLengthEnforcement();
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 related to the deprecation at all or just an improvement?

@AlexV525
Copy link
Member Author

After the flutter/tests#72 get's merged, customer tests will be succeed.

@AlexV525 AlexV525 merged commit 63062a6 into flutter:master Dec 13, 2020
@AlexV525 AlexV525 deleted the deprecate-max-length-enforced branch December 13, 2020 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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