-
Notifications
You must be signed in to change notification settings - Fork 106
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
Interdependent items builder #175
Conversation
A new interdependent builder has been added to construct a more efficient, complex GroupedListView where the current element is dependent on its neighboring elements.
Dart SDK increased from version 2.12 to 2.17 due to new functionalities only available for the new version.
The chat example app has been upgraded to include a more realistic implementation of a chat timeline, utilizing the new interdependent builder. Additionally, an infinite timeline feature was added to test the performance of the new method.
I added a test case to verify that the previous, current, and next elements are delivered in the expected order, in various list sizes and sort orders.
lib/grouped_list.dart
Outdated
@@ -358,13 +363,25 @@ class _GroupedListViewState<T, E> extends State<GroupedListView<T, E>> { | |||
/// Returns the widget for element positioned at [index]. The widget is | |||
/// retrieved either by [widget.indexedItemBuilder] or [widget.itemBuilder]. | |||
Widget _buildItem(context, int index) { | |||
final int elementsLength = _sortedElements.length; |
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.
Useless to declare it as a variable, just use _sortedElements.length in the one place needed
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
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.
I also did the same thing for the variables key
and value
for the same reason.
Changed requested
Changed realized to reduce the number of operation inside _buildItem method
Commentary updated
Thank you for your contribution, lgtm! |
Due to difficulties implementing a chat app using the
GroupedListView
widget with the currentitemBuilder
andindexedItemBuilder
methods, I added a new builder calledinterdependentItemBuilder
to construct the items while bringing in the previous, current, and next elements on each step, resulting in better performance.I also added:
interdependentItemBuilder
method.Here is a print screen of the new Chat Example App: