Share content, text, and images in your WebF applications
Version 1.0.0
Share images, text, and URLs using native platform sharing mechanisms like iOS UIActivityViewController and Android Share Intent.
Save screenshots to device storage with platform-specific handling for iOS, Android, and macOS.
Create preview images for temporary display in your app before sharing or saving.
Works seamlessly on iOS, Android, and macOS with platform-specific storage and sharing mechanisms.
1dependencies:
2 webf_share: ^1.0.01import 'package:webf/webf.dart';
2import 'package:webf_share/webf_share.dart';
3
4void main() {
5 // Register module globally
6 WebF.defineModule((context) => ShareModule(context));
7 runApp(MyApp());
8}1npm install @openwebf/webf-share1import { WebFShare } from '@openwebf/webf-share';
2
3const success = await WebFShare.shareText({
4 title: 'My App',
5 text: 'Check out this amazing content!',
6 url: 'https://example.com'
7});
8
9if (success) {
10 console.log('Content shared successfully');
11}1import { WebFShare, ShareHelpers } from '@openwebf/webf-share';
2
3// Get canvas element
4const canvas = document.querySelector('canvas');
5const imageData = await ShareHelpers.canvasToArrayBuffer(canvas);
6
7// Share the image
8await WebFShare.shareImage({
9 imageData,
10 text: 'Check out my creation!',
11 subject: 'My App - Amazing Creation'
12});1import { WebFShare, ShareHelpers } from '@openwebf/webf-share';
2
3// Capture and save screenshot
4const canvas = document.querySelector('canvas');
5const imageData = await ShareHelpers.canvasToArrayBuffer(canvas);
6
7const result = await WebFShare.saveScreenshot({
8 imageData,
9 filename: 'my_screenshot'
10});
11
12if (result.success) {
13 console.log('Saved to:', result.filePath);
14 alert('Screenshot saved to device!');
15}1import { WebFShare, ShareHelpers } from '@openwebf/webf-share';
2
3// Save for preview
4const canvas = document.querySelector('canvas');
5const imageData = await ShareHelpers.canvasToArrayBuffer(canvas);
6
7const previewResult = await WebFShare.saveForPreview({
8 imageData,
9 filename: 'preview_image'
10});
11
12// Display the preview
13const img = document.createElement('img');
14img.src = previewResult.filePath;
15img.style.maxWidth = '100%';
16document.body.appendChild(img);Files are saved to /storage/emulated/0/Download/ when accessible, or to app-specific external storage.
Files saved to Downloads are accessible system-wide through the Files app.
Files are saved to the app's documents directory.
Files are accessible through the Files app.
Files are saved to the application's documents directory.
Files are accessible through Finder.