I'm using url_launcher to send email with system email in my app. I'm using code below and this guy is doing so well.
void launchEmailSubmission() async {
final Uri params = Uri(
scheme: 'mailto',
path: 'myOwnEmailAddress@gmail.com',
);
String url = params.toString();
if (await canLaunch(url)) {
await launch(url);
} else {
print('Could not launch $url');
}
}
But now I want to give it 'default' subject and hintText inside the mail body box(if hintText not possible, then normal text).
Is there any way to do this?
Try using queryParameters
in Uri
. You can achieve this in below shown way:
void launchEmailSubmission() async {
final Uri params = Uri(
scheme: 'mailto',
path: 'myOwnEmailAddress@gmail.com',
queryParameters: {
'subject': 'Default Subject',
'body': 'Default body'
}
);
String url = params.toString();
if (await canLaunch(url)) {
await launch(url);
} else {
print('Could not launch $url');
}
}
It will open will default body and subject.