Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;


/** FlutterSharePlugin */
public class FlutterSharePlugin implements FlutterPlugin, MethodCallHandler {
Expand All @@ -28,13 +26,6 @@ public class FlutterSharePlugin implements FlutterPlugin, MethodCallHandler {

public FlutterSharePlugin() {}

/** Plugin registration. */
@SuppressWarnings("deprecation")
public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
final FlutterSharePlugin instance = new FlutterSharePlugin();
instance.onAttachedToEngine(registrar.context(), registrar.messenger());
}

@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger());
Expand Down Expand Up @@ -65,15 +56,13 @@ public void onMethodCall(MethodCall call, Result result) {
}

private void share(MethodCall call, Result result) {
try
{
try {
String title = call.argument("title");
String text = call.argument("text");
String linkUrl = call.argument("linkUrl");
String chooserTitle = call.argument("chooserTitle");

if (title == null || title.isEmpty())
{
if (title == null || title.isEmpty()) {
Log.println(Log.ERROR, "", "FlutterShare Error: Title null or empty");
result.error("FlutterShare: Title cannot be null or empty", null, null);
return;
Expand Down Expand Up @@ -108,25 +97,21 @@ private void share(MethodCall call, Result result) {
context.startActivity(chooserIntent);

result.success(true);
}
catch (Exception ex)
{
} catch (Exception ex) {
Log.println(Log.ERROR, "", "FlutterShare: Error");
result.error(ex.getMessage(), null, null);
}
}

private void shareFile(MethodCall call, Result result) {
try
{
try {
String title = call.argument("title");
String text = call.argument("text");
String filePath = call.argument("filePath");
String fileType = call.argument("fileType");
String chooserTitle = call.argument("chooserTitle");

if (filePath == null || filePath.isEmpty())
{
if (filePath == null || filePath.isEmpty()) {
Log.println(Log.ERROR, "", "FlutterShare: ShareLocalFile Error: filePath null or empty");
result.error("FlutterShare: FilePath cannot be null or empty", null, null);
return;
Expand All @@ -152,9 +137,7 @@ private void shareFile(MethodCall call, Result result) {
context.startActivity(chooserIntent);

result.success(true);
}
catch (Exception ex)
{
} catch (Exception ex) {
result.error(ex.getMessage(), null, null);
Log.println(Log.ERROR, "", "FlutterShare: Error");
}
Expand Down