Make naming consistent across channel APIs (#9270)

This commit is contained in:
Mikkel Nygaard Ravn
2017-04-18 15:23:15 +02:00
committed by GitHub
parent 752d6096a6
commit 945cfc3ee2
23 changed files with 150 additions and 151 deletions

View File

@@ -1,9 +1,9 @@
package {{androidIdentifier}};
import io.flutter.app.FlutterActivity;
import io.flutter.plugin.common.FlutterMethodChannel;
import io.flutter.plugin.common.FlutterMethodChannel.MethodCallHandler;
import io.flutter.plugin.common.FlutterMethodChannel.Response;
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.MethodCall;
/**
@@ -18,15 +18,15 @@ public class {{pluginClass}} implements MethodCallHandler {
private {{pluginClass}}(FlutterActivity activity) {
this.activity = activity;
new FlutterMethodChannel(activity.getFlutterView(), "{{projectName}}").setMethodCallHandler(this);
new MethodChannel(activity.getFlutterView(), "{{projectName}}").setMethodCallHandler(this);
}
@Override
public void onMethodCall(MethodCall call, Response response) {
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("getPlatformVersion")) {
response.success("Android " + android.os.Build.VERSION.RELEASE);
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else {
response.notImplemented();
result.notImplemented();
}
}
}

View File

@@ -8,12 +8,14 @@
if (self) {
FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:@"{{projectName}}"
binaryMessenger:controller];
binaryMessenger:controller];
[channel setMethodCallHandler:^(FlutterMethodCall *call,
FlutterResultReceiver result) {
FlutterResult result) {
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice]
systemVersion]]);
} else {
result(FlutterMethodNotImplemented);
}
}];
}