Skip to Content

Share Plugin

Share content, text, and images in your WebF applications

Version 1.0.0

Features

Share Content

Share images, text, and URLs using native platform sharing mechanisms like iOS UIActivityViewController and Android Share Intent.

Save Screenshots

Save screenshots to device storage with platform-specific handling for iOS, Android, and macOS.

Preview Images

Create preview images for temporary display in your app before sharing or saving.

Cross-Platform Support

Works seamlessly on iOS, Android, and macOS with platform-specific storage and sharing mechanisms.

Installation

1. Add to pubspec.yaml

pubspec.yaml
1dependencies:
2  webf_share: ^1.0.0

2. Register the module

main.dart
1import '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}

3. Install npm package (JavaScript/TypeScript)

1npm install @openwebf/webf-share

Usage Examples

Share Text Content

ShareText.tsx
1import { 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}

Share Image from Canvas

ShareImage.tsx
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});

Save Screenshot to Device

SaveScreenshot.tsx
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}

Save for Preview and Display

SavePreview.tsx
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);

Platform Storage Locations

Android

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.

iOS

Files are saved to the app's documents directory.

Files are accessible through the Files app.

macOS

Files are saved to the application's documents directory.

Files are accessible through Finder.