share static method
Present the native share sheet for a file on disk.
sourceRect is the originating widget's rect in Flutter logical
pixels (global coordinates). Required on iPad and macOS (anchor for
the popover); ignored on iPhone, Android and Windows, whose share
window places itself. Pass null on iPad/macOS to center the
popover — typical fallback when the originating widget has been
disposed by the time bytes are ready.
mimeType hints Intent.setType on Android. Ignored on Apple
platforms and Windows (the share sheet infers from the file
extension).
title populates the subject hint (Mail subject on iOS, chooser
title on Android, the share window's title on Windows, which is the
file's name when title is null). Ignored on macOS.
Returns true if the sheet was presented, or false on Windows with no
window. Throws a PlatformException with no activity on Android
(no_activity) or no view on iOS and macOS (no_view).
Implementation
static Future<bool> share({
required String path,
String? title,
String? mimeType,
Rect? sourceRect,
}) async {
final result = await _channel.invokeMethod<bool>('share', {
'path': path,
'title': ?title,
'mimeType': ?mimeType,
if (sourceRect != null)
'sourceRect': {
'x': sourceRect.left,
'y': sourceRect.top,
'w': sourceRect.width,
'h': sourceRect.height,
},
});
return result ?? false;
}