Skip to content

Instantly share code, notes, and snippets.

@neiljaywarner
Created March 29, 2019 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neiljaywarner/055617a71ee1562bccd8a8b8695b80b6 to your computer and use it in GitHub Desktop.
Save neiljaywarner/055617a71ee1562bccd8a8b8695b80b6 to your computer and use it in GitHub Desktop.
Simple java file to separate and decouple Android platform call for Flutter a bit while still not having to publish at all.
package com.example.fluttergetstringdriver;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
public class GetStringPlugin implements MethodChannel.MethodCallHandler {
/** Plugin registration. */
public static void registerWith(PluginRegistry.Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "com.example.plugin");
channel.setMethodCallHandler(new GetStringPlugin());
}
@Override
public void onMethodCall(MethodCall call, MethodChannel.Result result) {
if (call.method.equals("plugin_hi")) {
result.success("Hello from GetStringPlugin");
} else {
result.notImplemented();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment