-
Notifications
You must be signed in to change notification settings - Fork 336
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
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); |
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: trailing comma
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.
Thanks, done!
decoration: const InputDecoration( | ||
contentPadding: EdgeInsets.all(denseSpacing), | ||
border: OutlineInputBorder(), | ||
focusedBorder: OutlineInputBorder(borderSide: BorderSide.none), | ||
enabledBorder: OutlineInputBorder(borderSide: BorderSide.none), | ||
labelText: 'Eval', | ||
), | ||
determineOverlayXPosition: |
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: how about the name
overlayXPositionBuilder
or similar for consistency with other similar APIs in Flutter.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good idea! Switched to that
@@ -556,6 +556,11 @@ typedef ClearSearchField = Function( | |||
bool force, | |||
}); | |||
|
|||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, renamed. Still using the typedef since it's being used twice
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.
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.
tracking
which iftrue
would display the autocomplete overlay over the cursor.
in the expression (if there is a.
).Demo:
This PR is part of the work towards #3095