Created
March 29, 2019 16:11
-
-
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.
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 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