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

Each page returns bufferSize + 1 contacts #25

Closed
dere-app opened this issue Sep 19, 2020 · 3 comments
Closed

Each page returns bufferSize + 1 contacts #25

dere-app opened this issue Sep 19, 2020 · 3 comments

Comments

@dere-app
Copy link

Hello,

When setting a bufferSize for listContacts() each page returns bufferSize+1 contacts. For example, the code below will return a list of 6 contacts instead of 5, with the 6th contact containing mostly blank fields.

This is being run on Android 10 (API 29).

final int bufferSize = 5;
final pagingList = Contacts.listContacts(bufferSize: bufferSize);

if(await pagingList.moveNextPage()) {
    final List<Contact> contacts = await pagingList.currentPage;
    for(int i =0; i < contacts.length; ++i) {
        final Contact contact = contacts[i];
        print('CONTACT ($i):\n${contact.toMap()}\n\n');
    }
}

flutter doctor

[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.49.1)
[✓] Connected device (1 available) - Samsung Galaxy S9+

• No issues found!

Thanks

@dere-app dere-app changed the title Each page return bufferSize + 1 contacts Each page returns bufferSize + 1 contacts Sep 19, 2020
@gwxtr
Copy link
Contributor

gwxtr commented Sep 21, 2020

I can't test it at the moment, but by inspecting the code, replacing "lower than or equals" with "lower than" on line 83 in file contact-from-cursor-ext.kt, should solve the issue.

while (cursor.moveToNext() && contactsById.size <= limit) {

@ericmartineau
Copy link
Contributor

I finally tracked this down. It was a little more complicated than the logic operator, but I'm confident that it's fixed.

@ericmartineau
Copy link
Contributor

Version 0.6.4+2

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

No branches or pull requests

3 participants