From 2a958bd0df5cd1bf705a578c4969fba07240ed69 Mon Sep 17 00:00:00 2001 From: chakshu salgotra <44551619+chakshu21@users.noreply.github.com> Date: Fri, 2 Oct 2020 12:16:51 +0530 Subject: [PATCH] Create README_en.md --- README_en.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 README_en.md diff --git a/README_en.md b/README_en.md new file mode 100644 index 0000000..8205ecc --- /dev/null +++ b/README_en.md @@ -0,0 +1,64 @@ +# flutter_cpp_plugin + +#### Project Introduction: +Use C++ to write nuter plug-in, support android and ios platforms。 + +#### Instructions for use: + +Instruction in the pubspec.yaml file. + +``` +flutter_cpp_plugin: + path: flutter_cpp_plugin Directory + +``` + +Add your C++ code to plugins folder. + + +#### Code Example: + + +C++ Code: + +```C++ + +class TestPlugin:public JsonPlugin +{ +public: + TestPlugin() + :JsonPlugin("cppplugins.flutter.io/json_plugin") + { + + } + + virtual void HandleJsonMethodCall(const JsonMethodCall &method_call, + std::unique_ptr result) + { + if(method_call.method_name() == "hello") + { + Json::Value value=method_call.GetArgumentsAsJson(); + result->Success(&value); + + //transfer dart + InvokeMethod("hello",value); + } + } +}; + +``` + +dart Code: + +```dart + +MethodChannel jsonChannel = MethodChannel('cppplugins.flutter.io/json_plugin',JSONMethodCodec()); + +jsonChannel.setMethodCallHandler((MethodCall call){ + print("call from cpp plugin method ${call.method} arguments ${call.arguments}"); +}); + +final String strResult = await jsonChannel.invokeMethod('hello','world'); +assert(strResult=="world"); + +```