go-flutter-desktop / go-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
https://hover.build/
BSD 3-Clause "New" or "Revised" License
5.84k stars 286 forks source link

It is very difficult to transfer data between go language and flutter #676

Closed qinjinze closed 1 year ago

qinjinze commented 1 year ago

It is recommended to further improve data transmission. My suggestions are as follows. For example: Flutter sends data to Go language: flatterToGo.Send(“get”,“{”name“:”tom“,”age“:18}”);

Get the data sent by flutter in Go language code: fmt.Println(flutter.data(“get”).toJson)//{“name”:“tom”,“age”:18} fmt.Println(flutter.data(“get”)。 toString)//'{“name”:“tom”,“age”:18}'

Send data to flutter in Go language: GoToFlutter.Send(“hello”,“{”name“:”tom“,”age“:18}”);

Flutter obtains data sent from Go language: print(Go.data(“hello”,“{”name“:”tom“,”age“:18}”)。 To Json);//{ “name”:“tom”,“age”:18} print(Go.data(“hello”,“{”name“:”tom“,”age“:18}”)。 toJson);//’{ “name”:“tom”,“age”:18}'

The go plugin provides flutterToGo. Send() and Go. data() built-in methods. The go plug framework provides GoToFlutter. Send() and flutter. data() built-in methods;

pchampio commented 1 year ago

Checkout: https://github.com/go-flutter-desktop/examples/tree/master/plugin_tutorial/

And: https://github.com/go-flutter-desktop/examples/blob/d602b76d29b2fea00a7c60c968589613c24dd972/plugin_tutorial/go-plugin-example/complex/main.go#L67-L89

and: https://github.com/go-flutter-desktop/go-flutter/wiki/Implement-a-plugin

and for JSON: https://github.com/search?q=org%3Ago-flutter-desktop+JSONMethodCodec&type=code