open_file
open_file copied to clipboard
Fix for OpenFilePlugin
Hi, the OpenFilePlugin code has issues and causes problems in an Add-to-App scenario when FlutterActivity will be opened, then closed and re-opened again. This causes an exception in onAttachedToActivity during plugin initialization. The problem is creating the MethodChannel here is the wrong place as the global variable flutterPluginBinding is still null (the order of calling onAttachToEngine and onAttachedToActivity seams to change after launching FlutterActivity a second time).
I've done the following fix in my local code:
// Moved MethodChannel creation into onAttachedToEngine public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { this.flutterPluginBinding = binding; channel = new MethodChannel( binding.getBinaryMessenger(), "open_file"); channel.setMethodCallHandler(this); context = binding.getApplicationContext(); }
public void onAttachedToActivity(ActivityPluginBinding binding) {
activity = binding.getActivity();
binding.addRequestPermissionsResultListener(this);
binding.addActivityResultListener(this);
}
Please add the changes to to your code. Thanks
any update on the package!?!
A fix has been made at open_filex 4.3.2