mailto 0.1.4 mailto: ^0.1.4 copied to clipboard
Simple Dart package for creating mailto links in your Flutter apps
mailto
#
Simple Dart package for creating mailto links in your Flutter apps
This package helps you build mailto links and use those mailto links to launch the phone's email client with certain fields pre-filled, while taking care of encoding every fields properly.
The mailto
package:
- supports one or many
to
,cc
, andbcc
fields - supports custom body and subject for the emails
- encodes every value for your correctly
- is blazingly fast 😜
Important links #
- Read the source code and star the repo!
- Check package info on
pub.dev
- Open an issue
- Read the docs
- This Dart package is created by the SMAHO development team.
Usage #
Most likely, you want to launch the email client on the phone with certain fields pre-filled.
import 'package:mailto/mailto.dart';
// Optional, but most likely what you want
import 'package:url_launcher/url_launcher.dart';
// Somewhere in your app
launchMailto() async {
final mailtoLink = Mailto(
to: ['to@example.com'],
cc: ['cc1@example.com', 'cc2@example.com'],
subject: 'mailto example subject',
body: 'mailto example body',
);
// Convert the Mailto instance into a string.
// Use either Dart's string interpolation
// or the toString() method.
await launch('$mailtoLink');
}
Use url_launcher
for launching the links you create with the mailto
package.
The package currently does not follow RFC 6068 - The 'mailto' URI Scheme, but it's planned to make sure that the package works well on all platforms and with all email clients.
Contribute #
Tests #
We use the test
package for writing and running tests.
Run the test locally by pub run test
.
Format #
We use the dartfmt
tool to automatically format our code in a way that follows the Dart guidelines.
Format your code by executing dartfmt -w .
.