flutter_qr_code_scanner_generator_sharing icon indicating copy to clipboard operation
flutter_qr_code_scanner_generator_sharing copied to clipboard

<asynchronous suspension>

Open ad-nagdeve28 opened this issue 2 years ago • 2 comments

MissingPluginException(No implementation found for method shareFile on channel channel: me.alfian.share/share) methodChannel._invokeMethod

ad-nagdeve28 avatar Aug 31 '21 09:08 ad-nagdeve28

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"));

}

abdelhamid22 avatar Sep 11 '21 11:09 abdelhamid22

but, this code are not flutter or dart code

ad-nagdeve28 avatar Sep 13 '21 08:09 ad-nagdeve28