QuisApp / flutter_contacts

MIT License
83 stars 138 forks source link

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

Closed ritwizkh closed 1 month ago

ritwizkh commented 3 months ago

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 commented 2 months ago

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

joachim-quis commented 1 month ago

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

joachim-quis commented 1 month ago

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 commented 1 month ago

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

igopi77 commented 1 month ago

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 commented 1 month ago

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