A WebF module for sharing content, text, and images in Flutter applications.
- ✅ Share images with text and subject
- ✅ Share text content and URLs
- ✅ Save screenshots to device storage
- ✅ Create preview images for display
- ✅ Cross-platform support (iOS, Android, macOS)
- ✅ Platform-specific storage handling
Add this to your pubspec.yaml:
dependencies:
webf_share: ^1.0.0 # Available on pub.devimport 'package:webf/webf.dart';
import 'package:webf_share/webf_share.dart';
// Register module globally (in main function)
WebF.defineModule((context) => ShareModule(context));npm install @openwebf/webf-shareimport { WebFShare, ShareHelpers } from '@openwebf/webf-share';
// Share text
const success = await WebFShare.shareText({
title: 'My App',
text: 'Check out this amazing content!',
url: 'https://example.com'
});
// Share image
const canvas = document.querySelector('canvas');
const imageData = await ShareHelpers.canvasToArrayBuffer(canvas);
await WebFShare.shareImage({
imageData,
text: 'Check out this amazing content!',
subject: 'My App - Amazing Content'
});
// Save screenshot
const result = await WebFShare.saveScreenshot({
imageData,
filename: 'my_screenshot'
});
if (result.success) {
console.log('Saved to:', result.filePath);
}
// Save for preview
const previewResult = await WebFShare.saveForPreview({
imageData,
filename: 'preview_image'
});
// Display the preview
const img = document.createElement('img');
img.src = previewResult.filePath;
document.body.appendChild(img);// Share image
const success = await webf.invokeModuleAsync('Share', 'share',
imageData,
'Check out this amazing content!',
'My App - Amazing Content'
);
// Share text
const success = await webf.invokeModuleAsync('Share', 'shareText', {
title: 'My App',
text: 'Check out this amazing content!',
url: 'https://example.com'
});
// Save screenshot
const result = await webf.invokeModuleAsync('Share', 'save',
imageData,
'my_screenshot'
);
// Save for preview
const result = await webf.invokeModuleAsync('Share', 'saveForPreview',
imageData,
'preview_image'
);- Downloads:
/storage/emulated/0/Download/(when accessible) - External Storage: App-specific external storage directory
- Access: Files saved to Downloads are accessible system-wide
- App Documents: App's documents directory
- Access: Files are accessible through the Files app
- Application Documents: App's documents directory
- Access: Files are accessible through Finder
The module uses the platform's native sharing mechanism:
- iOS: UIActivityViewController
- Android: Android Share Intent
- macOS: NSSharingService
Shares an image with optional text and subject.
Parameters:
imageData(ArrayBuffer): Binary image datatext(string): Text to include with the sharesubject(string): Subject line for the share
Returns: Promise<boolean> - true if successful
Shares text content with optional URL.
Parameters:
- Format 1:
[title, text](legacy) - Format 2:
[{title, text, url}](recommended)
Returns: Promise<boolean> - true if successful
Saves image to device storage.
Parameters:
imageData(ArrayBuffer): Binary image datafilename(string, optional): Custom filename without extension
Returns: Promise<Object> with save details
Saves image for temporary preview display.
Parameters:
imageData(ArrayBuffer): Binary image datafilename(string, optional): Custom filename for preview
Returns: Promise<Object> with file path for display
This package is part of the WebF project. See the main WebF license for details.