saveContact method

Future<void> saveContact()

Implementation

Future<void> saveContact() async {
  var phone = profile.mobileNumber.checkNull().isNotEmpty
      ? profile.mobileNumber.checkNull()
      : getMobileNumberFromJid(profile.jid.checkNull());
  var userName = profile.nickName.checkNull().isNotEmpty
      ? profile.nickName.checkNull()
      : profile.name.checkNull();
  if (phone.isNotEmpty) {
    lib_phone_number.init();
    var formatNumberSync = lib_phone_number.formatNumberSync(phone);
    var parse = await lib_phone_number.parse(formatNumberSync);
    debugPrint("parse-----> $parse");
    Mirrorfly.addContact(number: parse["international"], name: userName)
        .then((value) {
      if (value ?? false) {
        toToast(AppConstants.contactSaved);
        if (Constants.enableContactSync) {
          syncContacts();
        }
      }
    });
  } else {
    mirrorFlyLog('mobile number', phone.toString());
  }
}