sendEmail static method

Future sendEmail({
  1. required String email,
  2. String subject = "",
  3. String body = "",
})

Opens the email app to send an email to the given email with an optional subject and body.

Implementation

static Future sendEmail({
  required String email,
  String subject = "",
  String body = "",
}) async {
  try {
    final mail = Uri(
      scheme: "mailto",
      path: email,
      query: _encodeQueryParameters(<String, String>{
        "subject": subject,
        "body": body,
      }),
    );
    await launchUrl(mail);
  } catch (error, stackTrace) {
    ErrorLogger.instance.logError(
      error: error,
      stackTrace: stackTrace,
      file: "url_launcher_helper",
      event: "sendEmail",
    );
    return Future.error(error);
  }
}