Skip to content

Commit

Permalink
Fix that when you launch Mail with a template, the space character is…
Browse files Browse the repository at this point in the history
… a '+'.
  • Loading branch information
nilsreichardt committed Oct 19, 2024
1 parent 8be6c56 commit 254d377
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/url_launcher_extended/lib/src/url_launcher_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,22 @@ class UrlLauncherExtended {
String? subject,
String? body,
}) async {
final emailLaunchString = Uri(
scheme: 'mailto',
path: address,
queryParameters: {
if (subject != null) 'subject': subject,
if (body != null) 'body': body,
},
);
String url = 'mailto:$address';
if (subject != null) {
url += '?subject=$subject';
}
if (body != null) {
url += subject == null ? '?' : '&';
url += 'body=$body';
}

final canLaunch = await canLaunchUrl(emailLaunchString);
final uri = Uri.parse(url);
final canLaunch = await canLaunchUrl(uri);
if (!canLaunch) {
throw CouldNotLaunchMailException(address, subject: subject, body: body);
}

return launchUrl(emailLaunchString);
return launchUrl(uri);
}
}

Expand Down

0 comments on commit 254d377

Please sign in to comment.