Skip to content
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

Fixed suggestions list scrolling and sizing #18

Merged
merged 2 commits into from
Jan 5, 2019
Merged

Fixed suggestions list scrolling and sizing #18

merged 2 commits into from
Jan 5, 2019

Conversation

KaYBlitZ
Copy link
Contributor

@KaYBlitZ KaYBlitZ commented Jan 2, 2019

Spent a better part of the day fixing the suggestions list scrolling and resizing.

The list resizes now by setting a fixed height. The fixed height is changed whenever the keyboard is toggled on/off and then calling a rebuild. This means the list will resize to just above the keyboard or use up the entire screen.

Please edit as you see fit.

Great plugin!

@@ -628,7 +642,7 @@ class _TypeAheadFieldState<T> extends State<TypeAheadField<T>> {

this._suggestionsBoxController = _SuggestionsBoxController(context);

(() async {
WidgetsBinding.instance.addPostFrameCallback((duration) async {

Choose a reason for hiding this comment

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

I didn't understand the purpose of this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That code just adds a callback to be executed after the frame. Originally the code used

     while (renderBox == null) {	
       await Future.delayed(Duration(milliseconds: 10));	
 
        renderBox = context.findRenderObject();	
     }	
 
      while (!renderBox.hasSize) {	
       await Future.delayed(Duration(milliseconds: 10));	
     }

By waiting until after the frame, renderBox will be ready and we do not need to loop and wait.

That addPostFrameCallback line and removing the above code does not have an impact on the suggestions list sizing and scrolling.

I added it in because it made the code cleaner. It doesn't have an impact on performance either way. The callback is only called once as well, so it works well for its purpose.

Choose a reason for hiding this comment

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

Ohh interesting! thank you!

@AbdulRahmanAlHamali
Copy link
Owner

@KaYBlitZ Thank you for the pull request! It looks really neat, and the amount of effort is obvious!

I have reviewed your pull request and it looks very good overall, I will test it tonight, or by the weekend at max, and will release a new version with your contribution asap.

Thank you again!

@AbdulRahmanAlHamali AbdulRahmanAlHamali changed the base branch from master to develop January 5, 2019 18:47
@AbdulRahmanAlHamali AbdulRahmanAlHamali merged commit 781c97e into AbdulRahmanAlHamali:develop Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants