Skip to content

Fix inverted logic in makeExpertCall function causing phone dialer launch failure #338

@navaneeth0041

Description

@navaneeth0041

🐛 Describe the bug

The phone call functionality is not working properly in the LocalExpert feature. When users attempt to call an expert by tapping the phone icon, an alert dialog appears instead of launching the phone dialer. Upon investigation, this is caused by inverted conditional logic in the makeExpertCall function.

Future<void> makeExpertCall(
    LocalExpertEntity expertDetails, BuildContext context) async {
  final Uri phoneUri = Uri(scheme: 'tel', path: expertDetails.phoneNumber);

  if (!await canLaunchUrl(phoneUri)) {
    await launchUrl(phoneUri, mode: LaunchMode.externalApplication);
  } else {
    showAlertDialog(
      context,
      "Contact ${expertDetails.name}",
      "You can contact ${expertDetails.name} at ${expertDetails.phoneNumber}",
    );
  }

https://github.com/user-attachments/assets/636e603a-542e-4334-a3c6-b6f98f752070

}

The function does not produce an error traceback but exhibits incorrect behavior. The condition is checking
!await canLaunchUrl(phoneUri) which inverts the logic. The function attempts to launch the URL when canLaunchUrl returns false, and shows the dialog when it returns true, which is the opposite of the intended behavior.

WhatsApp.Video.2025-04-06.at.23.46.57.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions