5

I had integrated a mail to scheme in flutter using a url_launcher package. the subject and body were given as query parameters.

 final Uri _emailLaunchUri = Uri(
                  scheme: 'mailto',
                  path: 'mail@qapp.how',
                  queryParameters: {
                      'body':
                          'this is sample text'
                    } 
                );

This will give the text as this+is+sample+text in mail.

Shibin
  • 43
  • 4
Abhijith Konnayil
  • 4,067
  • 6
  • 23
  • 49
  • I encountered a similar problem in MATLAB which lead me to the question here: https://stackoverflow.com/questions/4737841/urlencoder-not-able-to-translate-space-character . Turns out the + character is a cannonical space character representation in encoded URIs – Col Bates - collynomial Apr 29 '21 at 13:04

1 Answers1

9

instead of queryParameters use query.

final Uri _emailLaunchUri = Uri(
                  scheme: 'mailto',
                  path: 'mail@qapp.how',
                  query:
                       'body=this is sample text',
                );
Abhijith Konnayil
  • 4,067
  • 6
  • 23
  • 49
  • 4
    if you have multiple queryParameters like "body" & "subject" just concatenate them with an "&". E.g. "query: 'body=$body&subject=$subject' – Carlit0 Jul 05 '22 at 17:07