-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Suggest predicate-based formatter in [FilteringTextInputFormatter] docs for whole string matching #107848
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
Suggest predicate-based formatter in [FilteringTextInputFormatter] docs for whole string matching #107848
Conversation
string predicates in its documentation. - Fixes flutter#78100
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/// preserve the existing [TextEditingValue.selection] to values it would now | ||
/// fall at with the removed characters. | ||
/// A [FilteringTextInputFormatter] also tries to preserve the existing | ||
/// [TextEditingValue.selection] and [TextEditingValue.composing], and adjusts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe add a "region" after "[TextEditingValue.composing]" to make this read better?
/// them accordingly if text within either of these ranges is replaced. | ||
/// | ||
/// This formatter is typically used to match potentially recurring [Pattern]s | ||
/// in the new [TextEditingValue], and it never completely rejects the new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe break this sentence up a little. It's super long with the two "and"s.
@goderbauer rephrased some of the new docs could you take a look again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM
/// [TextEditingValue] and falls back to the current [TextEditingValue] when the | ||
/// given [filterPattern] fails to match. Consider using a different | ||
/// [TextInputFormatter] such as: | ||
/// `TextInputFormatter.withFunction((oldValue, newValue) => regExp.hasMatch(newValue.text) ? newValue : oldValue)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you wrap this in a ```dart section to get nicer code formatting in docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
/// fall at with the removed characters. | ||
/// A [FilteringTextInputFormatter] also tries to preserve the existing | ||
/// [TextEditingValue.selection] and the [TextEditingValue.composing] region, | ||
/// adjusting them accordingly if text within either of these ranges is replaced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is it also possible that that text before these ranges is replaced and they need to be updated? Not sure but just being pedantic.
/// for accepting/rejecting new input based on a predicate on the full string. | ||
/// As an example, [FilteringTextInputFormatter] typically shouldn't be used | ||
/// with [RegExp]s that contain positional matchers (`^` or `$`) since these | ||
/// patterns are usually meant for matching the whole string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much more clear to me and I feel like I know what to do in both situations thanks to the examples 👍
|
…tter] docs for whole string matching (flutter/flutter#107848)
…tter] docs for whole string matching (flutter/flutter#107848)
…cs for whole string matching (flutter#107848)
Explains when not to use a
FilteringTextInputFormatter
.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.