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

Null in openExternalPick() Response [Android 13] #161

Closed
ritwizkh opened this issue May 29, 2024 · 6 comments
Closed

Null in openExternalPick() Response [Android 13] #161

ritwizkh opened this issue May 29, 2024 · 6 comments

Comments

@ritwizkh
Copy link

I am using the latest version of the flutter_contacts: ^1.1.8 to pick the contact from native Android.
The compile apk is working fine on my old device, i.e android 9, but when I am trying the same app on Android 13, it opens the native contacts app, selects the contact, but it's returning Null.
Note: The contact permission is already granted to the app, but still facing issues on Android 13. I didn't test it on iOS.

I am using this in Flutterflow, here is the code which I am using:

import 'package:flutter_contacts/flutter_contacts.dart';
Future<ContactPickStruct?> contactPickOpen() async {
final pickedContact = await FlutterContacts.openExternalPick();

    if (pickedContact != null) {
      // Parse contact details inline
      final name = pickedContact.name;
      final personName =
          (name.first.isNotEmpty) ? '${name.first} ${name.last}'.trim() : '';
      final companyName = pickedContact.organizations.isNotEmpty
          ? pickedContact.organizations.first.company
          : '';
      final designation = pickedContact.organizations.isNotEmpty
          ? pickedContact.organizations.first.title
          : '';

      final mobileNumbers =
          pickedContact.phones.map((phone) => phone.number).toList();
      final emails =
          pickedContact.emails.map((email) => email.address).toList();
}
...
}
@ritwizkh
Copy link
Author

@joachim-quis - can you please look into this?

@joachim-quis
Copy link
Contributor

Hi @ritwizkh - is pickedContact null or is the result of contactPickOpen() null?

@joachim-quis
Copy link
Contributor

If it's pickedContact, could you add some debug print statements in this function to see where exactly the function is not working as intended?

@joachim-quis
Copy link
Contributor

Nevermind - this should now be fixed in version 1.1.9+1. Please reopen if not.

@igopi77
Copy link

igopi77 commented Aug 2, 2024

I tested on Android 13, Android 14, and Android 11, and it’s working fine I suspect the problem may not be related to the Android version.

@qoiu
Copy link

qoiu commented Aug 12, 2024

I am using the latest version 1.1.9+2 and have same bug on Android 13. Android 12, emulator is fine. In permission add
uses-permission android:name="android.permission.READ_CONTACTS"
uses-permission android:name="android.permission.WRITE_CONTACTS"
Maybe, I don't use some permission?
There's strange thing: it take only my first contact, but others return null

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

4 participants