AOSSIE-Org / AOSSIE-Org/Monumento
Fix inverted logic in makeExpertCall function causing phone dialer launch failure
- Dominant language
- Dart
- Stars
- 54
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
### 🐛 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 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.
https://github.com/user-attachments/assets/fe13e164-d303-4b74-b44f-83eacf2110e2
Contributor guide
Assessment
This issue has not been assessed yet.