flutter_qr_code_scanner_generator_sharing
flutter_qr_code_scanner_generator_sharing copied to clipboard
<asynchronous suspension>
MissingPluginException(No implementation found for method shareFile on channel channel: me.alfian.share/share) methodChannel._invokeMethod
You need add the below code in MainActivity class in android folder
private static final String SHARE_CHANNEL = "channel:me.alfian.share/share";
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(this.getFlutterView(), SHARE_CHANNEL).setMethodCallHandler(new MethodChannel.MethodCallHandler() {
public final void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
if (methodCall.method.equals("shareFile")) {
shareFile((String) methodCall.arguments);
}
}
});
}
and add the below function in the same class under method onCreate private void shareFile(String path) { File imageFile = new File(this.getApplicationContext().getCacheDir(), path); Uri contentUri = FileProvider.getUriForFile(this, "me.alfian.share", imageFile); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
this.startActivity(Intent.createChooser(shareIntent, "Share image using"));
}
but, this code are not flutter or dart code