Skip to content

fix: add error handling for launchUrl in Map screen#3401

Merged
marcnause merged 1 commit into
fossasia:mainfrom
prajakta128:fix/map-screen-launchurl-crash
Jul 6, 2026
Merged

fix: add error handling for launchUrl in Map screen#3401
marcnause merged 1 commit into
fossasia:mainfrom
prajakta128:fix/map-screen-launchurl-crash

Conversation

@prajakta128

Copy link
Copy Markdown
Contributor

Fixes #3400

Problem

The OpenStreetMap attribution link in lib/view/map_screen.dart called launchUrl() directly with no canLaunchUrl check and no error handling. If the URL fails to launch for any reason (no browser, network issue), the app throws an unhandled exception and crashes.

Root Cause

The onTap handler used a fire-and-forget launchUrl call with no guard, unlike other links in the app which already use canLaunchUrl correctly.

Fix

Added canLaunchUrl check and logger.e() for the failure case, consistent with the existing pattern already used in about_us_screen.dart, faq_screen.dart and connect_device_screen.dart.

Impact

  • Prevents app crash when the OpenStreetMap attribution URL cannot be launched
  • Consistent with existing error handling pattern in the app
  • No UI change

Screenshots / Recordings

N/A — crash fix, no UI changes

Checklist

  • No hard coding: I have used values from constants.dart or localization files instead of hard-coded values.
  • No end of file edits: No modifications done at end of resource files.
  • Code reformatting: I have formatted the code using dart format or the IDE formatter.
  • Code analysis: My code passes checks run in flutter analyze and tests run in flutter test.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @prajakta128, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Build Status

Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/28768630489/artifacts/8100154005.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

The OpenStreetMap attribution link in map_screen.dart called
launchUrl() directly with no canLaunchUrl check and no error
handling. If the URL fails to launch for any reason, the app
throws an unhandled exception and crashes.

Added canLaunchUrl check and logger.e() for the failure case,
consistent with how the same issue is already handled in
about_us_screen.dart, faq_screen.dart and connect_device_screen.dart.

Fixes fossasia#3400
@marcnause marcnause force-pushed the fix/map-screen-launchurl-crash branch from 331416e to b21959d Compare July 6, 2026 17:09
@marcnause marcnause merged commit d57931e into fossasia:main Jul 6, 2026
14 of 15 checks passed
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

Successfully merging this pull request may close these issues.

bug: launchUrl in Map screen crashes app when URL cannot be launched

2 participants