Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin部分,js调用dart为什么要传pageName? #304

Open
yx-mike opened this issue May 19, 2023 · 0 comments
Open

Plugin部分,js调用dart为什么要传pageName? #304

yx-mike opened this issue May 19, 2023 · 0 comments

Comments

@yx-mike
Copy link

yx-mike commented May 19, 2023

问题

定了Plugin,js和dart都写好,iOS也调通了,但是Android确不行?缺少"pageName"

我看了这部分Java的实现逻辑,pageName的作用主要是,在dart返回之后回调js方法时候指定上下文GLOBAL[pageName],就是指定js方法的this。
但是iOS没有这样的逻辑。

其实我不是很理解,对于公用的Plugin模块,为什么要在invokeFlutterCommonChannel方法返回时候绑定this到pageName,
如果是想回调给pageName,不是可以在调用插件时候传callback function吗。

现在的状况就是,所有Plugin调用都必须加上#FairKey#参数,在Plugin的js代码中又必须通过key“pageName”透传#FairKey#。

其实大部分情况下,Plugin的dart方法都不需要#FairKey#,除非想通过#FairKey#去获取当前dart中的State。

环境信息

flutter doctor --verbose
[✓] Flutter (Channel vd/main, 2.5.1042, on macOS 13.3.1 22E772610a darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.5.1042 at /Users/hxd/Documents/flutter/flutter
    • Upstream repository ssh://[email protected]:60022/flutter/flutter.git
    • Framework revision a8cad5e28c (7 months ago), 2022-10-27 11:59:08 +0800
    • Engine revision b3af521a05
    • Dart version 2.14.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
dependencies:
  fair: 3.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant