Expression evaluation autocomplete overlay is positioned over the last . in the expression#3449
Conversation
. in the expression. in the expression
| /// Provided by clients to specify where the autocomplete overlay should be | ||
| /// positioned relative to the input text. | ||
| typedef DetermineOverlayXPosition = double Function( | ||
| String inputValue, TextStyle inputStyle); |
| enabledBorder: OutlineInputBorder(borderSide: BorderSide.none), | ||
| labelText: 'Eval', | ||
| ), | ||
| determineOverlayXPosition: |
There was a problem hiding this comment.
nit: how about the name
overlayXPositionBuilder
or similar for consistency with other similar APIs in Flutter.
There was a problem hiding this comment.
Done, switched to overlayXPositionBuilder
| (String inputValue, TextStyle inputStyle) { | ||
| // X-coordinate is equivalent to the width of the input text | ||
| // up to the last "." or the insertion point (cursor): | ||
| final textSegment = inputValue.contains('.') |
There was a problem hiding this comment.
nit: slightly cleaner is:
final indexOfDot = inputValue.lastIndexOf('.')
final textSegment = indexOfDot != -1 ? inputValue.substring(0, indexOfDot + 1) : inputValue;A little better as it doesn't have two different expressions with the same goal (contains and lastIndexOf) and is a little faster due to less dupe work not that it matters in this particular case.
There was a problem hiding this comment.
Ah good idea! Switched to that
|
|
||
| /// Provided by clients to specify where the autocomplete overlay should be | ||
| /// positioned relative to the input text. | ||
| typedef DetermineOverlayXPosition = double Function( |
There was a problem hiding this comment.
also rename this to match the new name. Consider not using a typedef unless you think it adds value. I think the typedef is only used once so probably would be reasonable to remove.
There was a problem hiding this comment.
Done, renamed. Still using the typedef since it's being used twice

trackingwhich iftruewould display the autocomplete overlay over the cursor.in the expression (if there is a.).Demo:
This PR is part of the work towards #3095