share method
Share text.
Implementation
@override
Future<void> share(
String text, {
String? subject,
Rect? sharePositionOrigin,
}) async {
final queryParameters = {
if (subject != null) 'subject': subject,
'body': text,
};
// see https://github.com/dart-lang/sdk/issues/43838#issuecomment-823551891
final uri = Uri(
scheme: 'mailto',
query: queryParameters.entries
.map((e) =>
'${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}')
.join('&'),
);
final launchResult = await urlLauncher.launchUrl(
uri.toString(),
const LaunchOptions(),
);
if (!launchResult) {
throw Exception('Failed to launch $uri');
}
}