A Flutter plugin for sharing file & text with other applications.
Note for iOS
Your flutter's iOS code needs to be in swift. Otherwise you will get error:
=== BUILD TARGET flutter_inappbrowser OF PROJECT Pods WITH CONFIGURATION Debug === The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.
Instead, if you have already a non-swift project, you can check this issue to solve the problem: Friction adding swift plugin to objective-c project.
Note for Android
Your android support libraries needs to be of androidx. If you want to migrate your android project to androidx, you can take help from Migrating to AndroidX
WcFlutterShare.share( sharePopupTitle: 'Share', subject: 'This is subject', text: 'This is text', mimeType: 'text/plain');
Share file only:
final ByteData bytes = await rootBundle.load('assets/wisecrab.png'); await WcFlutterShare.share( sharePopupTitle: 'share', fileName: 'share.png', mimeType: 'image/png', bytesOfFile: bytes.buffer.asUint8List());
Share file, text and subject:
final ByteData bytes = await rootBundle.load('assets/wisecrab.png'); await WcFlutterShare.share( sharePopupTitle: 'share', subject: 'This is subject', text: 'This is text', fileName: 'share.png', mimeType: 'image/png', bytesOfFile: bytes.buffer.asUint8List());
NOTE: You won't be able to share image and text simultaneously on some applications. It is not a bug of this plugin. Some applications don't support this. I have tested this on Skype, on which is working fine.
Check out the example app in the Repository for further information.
- Foreign Function Interface for interoperability with the C programming language. [...]
- HTML elements and other resources for web-based applications that need to interact with the browser and the DOM (Document Object Model). [...]
- Utility methods to efficiently manipulate typed JSInterop objects in cases where the name to call is not known at runtime. You should only use these methods when the same effect cannot be achieved with @JS annotations. These methods would be extension methods on JSObject if Dart supported extension methods.