思考题实现思路
dart层设置颜色参数的方法:
changeBackgroundColor(int r, int g, int b) async
{
_channel.invokeMethod('changeBackgroundColor', {"r":r, "g":g, "b":b});
}
dart层调用:
controller.changeBackgroundColor(0, 255, 255)
android native层实现:
if (methodCall.method.equals("changeBackgroundColor")) {
int r = methodCall.argument("r");
int g = methodCall.argument("g");
int b = methodCall.argument("b");
view.setBackgroundColor(Color.rgb(r, g, b));
result.success(0);
}else {
result.notImplemented();
}
展开