d-silveira / flutter-share Goto Github PK
View Code? Open in Web Editor NEWcomplete flutter share plugin
License: BSD 3-Clause "New" or "Revised" License
complete flutter share plugin
License: BSD 3-Clause "New" or "Revised" License
when sending an intent its possible to add a package to specify which intentReceiver should handle it to circumvent the chooser at the bottom im not entirely certain if ios has a similar feature but i feel they should
Hi,
I tried this plugin and on code its look wonderful. but when I tried this in real device its make an exception, and I don't know how to fix it.
my code is:
// Core
import 'package:flutter/material.dart';
// Plugins
import 'package:share/receive_share_state.dart';
import 'package:share/share.dart';
class ShareServices extends StatefulWidget {
static const String routeName = '/share';
ShareServices({Key key}) : super(key: key);
@override
_ShareServicesState createState() => new _ShareServicesState();
}
class _ShareServicesState extends ReceiveShareState<ShareServices> {
@override
void receiveShare(Share shared) {
// TODO: implement receiveShare
print('shared mimeType is: ${shared.mimeType}');
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(title: new Text('Share to'))
);
}
}
this code compile without any error.
but after the sharing of an image for example I have this exception:
E/libEGL (28713): eglMakeCurrent:866 error 3002 (EGL_BAD_ACCESS)
E/flutter (28713): [ERROR:flutter/shell/platform/android/android_context_gl.cc(217)] Could not make the context current
E/flutter (28713): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_BAD_ACCESS (12290)
I/FlutterActivityDelegate(28713): onResume setting current activity to this
E/BpSurfaceComposerClient(28713): Failed to transact (-1)
E/BpSurfaceComposerClient(28713): Failed to transact (-1)
My Flutter Doctor is:
C:\flutter\bin\flutter.bat --no-color doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.4.4, on Microsoft Windows [Version 10.0.16299.431], locale he-IL)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[√] VS Code, 64-bit edition (version 1.23.1)
[√] Connected devices (1 available)
• No issues found!
Process finished with exit code 0
Gmail says it cannot add the file as attachment.
await Share.file(title: 'dump.dat', path: path, text: 'Dump').share();
it says no error. But path is correct and i can read file from within the app at that given path
Can you please publish this package on dart pub ?
I am not comfortable by putting git repo url in dependencies.
Can I capture a text that another application shares with this library?
` Share.share(
' ${forthmodel[position].name}'+':'
I want to change the name for sharing option name , but it is showing android name
await Share.file(
path: "file://" +app.apkFilePath,
mimeType: ShareType.TYPE_FILE,
title: "Something",
text:"Ok lets try")
I am using this firstI was using only app.apkFilePath but after reading 1 issue
I tried adding file:// before that but when I share , it shares only text can anybody help me
out
And yes one more thaing that if I am trying wihtout text I am getting error saying
non empty text
E/MethodChannel#plugins.flutter.io/share(30208): Failed to handle method call
E/MethodChannel#plugins.flutter.io/share(30208): java.lang.IllegalArgumentException: Non-empty text expected
E/MethodChannel#plugins.flutter.io/share(30208): at io.flutter.plugins.share.Share.share(Share.java:34)
E/MethodChannel#plugins.flutter.io/share(30208): at io.flutter.plugins.share.MethodCallHandler.onMethodCall(MethodCallHandler.java:27)
E/MethodChannel#plugins.flutter.io/share(30208): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:226)
E/MethodChannel#plugins.flutter.io/share(30208): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#plugins.flutter.io/share(30208): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:631)
E/MethodChannel#plugins.flutter.io/share(30208): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/share(30208): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/share(30208): at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#plugins.flutter.io/share(30208): at android.app.ActivityThread.main(ActivityThread.java:6692)
E/MethodChannel#plugins.flutter.io/share(30208): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/share(30208): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/share(30208): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (30208): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Non-empty text expected, null)
E/flutter (30208): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (30208): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (30208): <asynchronous suspension>
E/flutter (30208): #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
E/flutter (30208): #3 Share.share (package:share/share.dart:218:20)
E/flutter (30208): #4 _ApkExtractorState.getList.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:apkextractor/main.dart:151:48)
E/flutter (30208): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
E/flutter (30208): #6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
E/flutter (30208): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (30208): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:504:11)
E/flutter (30208): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:282:5)
E/flutter (30208): #10 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:217:7)
E/flutter (30208): #11 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:475:9)
E/flutter (30208): #12 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (30208): #13 PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (30208): #14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (30208): #15 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (30208): #16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (30208): #17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (30208): #18 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (30208): #19 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (30208): #20 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (30208): #21 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (30208): #22 _rootRunUnary (dart:async/zone.dart:1196:13)
E/flutter (30208): #23 _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (30208): #24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (30208): #25 _invoke1 (dart:ui/hooks.dart:275:10)
E/flutter (30208): #26 _dispatchPointerDataPacket (dart:ui/hooks.dart:184:5)
E/flutter (30208):
In Share
object there is a path
property.
How do I get the image from it ?
I get a an error saying file format not supported for pdf files. I have complete path of my file still i am unable to share it
Hi,
Thank you for your library.
I've got a weird bug, I've tried to attach a file but it show me the path and all the informations.
Any idea?
Share.image(path: testFile.path, mimeType: ShareType.TYPE_IMAGE, title:'Test Sharing' , text:'http://www.airswop.com').share();
/var/mobile/Containers/Data/Application/9DBEABE0-931F-4561-AEA9-0523727BB253/Documents/Test-Share.png Test Sharing http://www.test.com image/*
Is there a way to convert the Share received by the receiveShare-Method to a File-Type?
The Share I receive has the mimeType "*/*" and a content URI as path ("content://media/external/file/66797)
Hi,
Will this allow me to receive the tel:// link text I've registered in my manifest file?
Thanks.
I/flutter (29128): The following MissingPluginException was thrown while activating platform stream on channel I/flutter (29128): plugins.flutter.io/receiveshare: I/flutter (29128): MissingPluginException(No implementation found for method listen on channel I/flutter (29128): plugins.flutter.io/receiveshare)
`Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v0.7.3-pre.26, on Linux, locale cs_CZ.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
[✓] Connected devices (1 available)
• No issues found!
`
Is receiving intents on iOS still being worked on? Specifically, receiving file share intents. Just after a quick update on the status of this project.
I am trying to share an assets file but the file is not attaching, please see the attached image.
This is what I did for making a copy of asset's file in temp path:
Directory tempDir = await getTemporaryDirectory();
String tempPath = tempDir.path;
//fileName = assets folder's filename
String filePath = join(tempPath, fileName);
ByteData data = await rootBundle.load(join(assetPath, fileName));
List<int> bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
await File(filePath).writeAsBytes(bytes);
I/flutter ( 6676): ══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
I/flutter ( 6676): The following MissingPluginException was thrown while activating platform stream on channel
I/flutter ( 6676): plugins.flutter.io/receiveshare:
I/flutter ( 6676): MissingPluginException(No implementation found for method listen on channel
I/flutter ( 6676): plugins.flutter.io/receiveshare)
I/flutter ( 6676):
I/flutter ( 6676): When the exception was thrown, this was the stack:
I/flutter ( 6676): #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:278:7)
I/flutter ( 6676): <asynchronous suspension>
I/flutter ( 6676): #1 EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:418:29)
I/flutter ( 6676): <asynchronous suspension>
I/flutter ( 6676): #6 ReceiveShareState.enableShareReceiving (package:share/receive_share_state.dart:23:43)
I/flutter ( 6676): #7 _AppRootState.build (file:///Flutter%20Workspace/digital_frame/lib/main.dart:87:5)
I/flutter ( 6676): #8 StatefulElement.build (package:flutter/src/widgets/framework.dart:3730:27)
I/flutter ( 6676): #9 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3642:15)
I/flutter ( 6676): #10 Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter ( 6676): #11 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter ( 6676): #12 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3769:11)
I/flutter ( 6676): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6676): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6676): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6676): #16 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:857:16)
I/flutter ( 6676): #17 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:828:5)
I/flutter ( 6676): #18 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:774:17)
I/flutter ( 6676): #19 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2222:19)
I/flutter ( 6676): #20 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:773:13)
I/flutter ( 6676): #21 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:662:7)
I/flutter ( 6676): #22 runApp (package:flutter/src/widgets/binding.dart:704:7)
I/flutter ( 6676): #23 main.<anonymous closure> (file:////Flutter%20Workspace/digital_frame/lib/main.dart:55:7)
I/flutter ( 6676): #30 StorageH.getJSON (package:digital_frame/services/storage.services.dart)
I/flutter ( 6676): <asynchronous suspension>
I/flutter ( 6676): #31 main (file:// Flutter%20Workspace/digital_frame/lib/main.dart:39:14)
I/flutter ( 6676): <asynchronous suspension>
I/flutter ( 6676): #32 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
I/flutter ( 6676): #33 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
I/flutter ( 6676): (elided 10 frames from package dart:async)
I/flutter ( 6676): ════════════════════════════════════════════════════════════════════════════════════════════════════
Anyone know why that happen ?
When I add this code to my MainActivity.kt in Kotlin, I get the following error,
MainActivity.kt: (10, 5): 'configureFlutterEngine' overrides nothing
My MainActivityFile
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant
import io.flutter.plugins.share.FlutterShareReceiverActivity;
class MainActivity: FlutterShareReceiverActivity() {
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
}
}
Any help is appreciated. The feature of receiving shared files is critical to my apps functionality.
Thanks in advance
I'm getting a permission denied whenever I try to share a file to Gmail. Is it possible something like this needs to be set: https://developer.android.com/training/secure-file-sharing/share-file (check "grant file permissions") section
Hi @d-silveira I have another problem.
This plugin working good on share of one thing. But when I share my app with intent of multiple files I got exception on your code, (my code not running at all).
This is the log of my application:
E/flutter (27120): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_BAD_ACCESS (12290)
I/MainActivity(27120): receiving shared files!
I/flutter (27120): Share received - {0: content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fshare_image_1516813324332.png, 1: content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2Fshare_image_1516813378399.png, type: image/png, is_multiple: true}
E/flutter (27120): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (27120): 'package:share/share.dart': Failed assertion: line 83 pos 15: 'path != null': is not true.
E/flutter (27120): #0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:37:39)
E/flutter (27120): #1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:33:5)
E/flutter (27120): #2 new Share.file (package:share/share.dart)
E/flutter (27120): #3 Share.fromReceived (package:share/share.dart:141:24)
E/flutter (27120): #4 ReceiveShareState._receiveShareInternal (package:share/receive_share_state.dart:40:24)
E/flutter (27120): #5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (27120): #6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter (27120): #7 _DelayedData.perform (dart:async/stream_impl.dart:578:14)
E/flutter (27120): #8 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter (27120): #9 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter (27120): #10 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (27120): #11 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
I/FlutterActivityDelegate(27120): onResume setting current activity to this
E/BpSurfaceComposerClient(27120): Failed to transact (-1)
E/BpSurfaceComposerClient(27120): Failed to transact (-1)
I/zygote64(27120): Do partial code cache collection, code=60KB, data=47KB
I/zygote64(27120): After code cache collection, code=60KB, data=47KB
I/zygote64(27120): Increasing code cache capacity to 256KB````
Hello,
I'd like to share PDF files with another apps (both on Android and iOS).
Could you give me an example to use Share.file(path: <String>, mimeType: ShareType, title: , text: );
?
These files are in app's download directory.
Thanks in advance!
I tried using this library for receiving share intents (text).
It works fine for apps which has developed their own sharing screen. For example: Amazon/Myntra
But it doesn't work with native sharing popup triggred by apps like: Chrome/Flipkart
Device: Samsung Galaxy S10+
Hi,
im trying to share an image through Share.image(...) but for every app the share is opened, a message is shown that the format is not supported.
Im writing the file to the external directory beforehand, in PNG format.
WhatsApp, GMail etc. are all displaying the format is not supported but i cant image they dont support PNG.
Is there something wrong with my share or what could be the reason?
var byteData = await image.toByteData(format: ImageByteFormat.png);
await File(path).writeAsBytes(byteData.buffer.asUint8List());
Share.image(path: 'content://$path',
mimeType: ShareType.TYPE_IMAGE).share();
Hi there,
let me congrat with you for your work on this plugin first of all.
Now, there's a big conflict between the plugin and the flutter engine. With your plugin installed when I run the app on my device two errors are thrown:
E/flutter (18954): [ERROR:flutter/shell/platform/android/android_context_gl.cc(217)] Could not make the context current
E/flutter (18954): [ERROR:flutter/shell/platform/android/android_context_gl.cc(53)] EGL Error: EGL_BAD_ACCESS (12290)
On debug mode this has no impact as you pointed out in #1, but in profile/release mode this causes an app crash on startup.
How to share url image then image show before share?
When share to facebook, all fields are blank, Any idea?
How can I use an image from the net's path?
Something like this:
Share.image(path: URL_FROM_INTERNET, mimeType: , title: , text: );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.