Created
July 15, 2019 15:23
-
-
Save miguelpruivo/4e5f38ead28c44ae0b83f04370b2814d to your computer and use it in GitHub Desktop.
A result wrapper for Flutter Android plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.ptech.cc.plugins.flutter; | |
import android.os.Handler; | |
import android.os.Looper; | |
import io.flutter.plugin.common.MethodChannel; | |
public class MethodResultWrapper implements MethodChannel.Result { | |
private MethodChannel.Result methodResult; | |
private Handler handler; | |
MethodResultWrapper(MethodChannel.Result result){ | |
methodResult = result; | |
handler = new Handler(Looper.getMainLooper()); | |
} | |
@Override | |
public void success(final Object result) { | |
handler.post( | |
new Runnable() { | |
@Override | |
public void run() { | |
methodResult.success(result); | |
} | |
}); | |
} | |
@Override | |
public void error(String s, String s1, Object o) { | |
} | |
@Override | |
public void notImplemented() { | |
handler.post( | |
new Runnable() { | |
@Override | |
public void run() { | |
methodResult.notImplemented(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment