liyufengrex / flutter_subscreen_plugin

flutter插件:支持 Android 设备双屏显示,主副屏皆使用 flutter 绘制,通过 channel 双引擎实现主副屏通信交互。
BSD 3-Clause "New" or "Revised" License
123 stars 24 forks source link

副屏无法create图像 #10

Open Deathislikethewind opened 1 year ago

Deathislikethewind commented 1 year ago

当调用webview_flutter调用create时,报错

_controller = WebViewController();

final ByteData? result = !kReleaseMode && debugProfilePlatformChannels ? await (binaryMessenger as _ProfiledBinaryMessenger).sendWithPostfix(name, '#$method', input) : await binaryMessenger.send(name, input); 这里的result返回的是null找不到create方法。

No implementation found for method create on channel flutter/platform_views

另外无法主副屏通讯的,可以尝试去FlutterSubscreenPlugin里自己手动改一下

onAttachedToActivity方法里的onSubFlutterEngineCreated方法不会被执行,所以要把里面的 FlutterSubScreenProvider.instance.flutterEngine?.let { engine -> onCreateViceChannel(engine.dartExecutor) }这个代码提到外面去,全部代码如下

override fun onAttachedToActivity(binding: ActivityPluginBinding) { //your plugin is now attached to an Activity val autoShowSubScreenWhenInit = context.resources.getBoolean(R.bool.autoShowSubScreenWhenInit) FlutterSubScreenProvider.instance.doInit(binding.activity, autoShowSubScreenWhenInit) FlutterSubScreenProvider.instance.flutterEngine?.let { engine -> onCreateViceChannel(engine.dartExecutor) } FlutterSubScreenProvider.instance.setFlutterSubCallback(object : IFlutterSubCallback { override fun onSubFlutterEngineCreated() { //副屏 engine 初始化后,将副屏事件进行分发 FlutterSubScreenProvider.instance.flutterEngine?.let { engine -> onCreateViceChannel(engine.dartExecutor) } } }) }

cwangfr commented 1 year ago

感谢提供方案,亲测好用 @Deathislikethewind

liyufengrex commented 1 year ago

感谢反馈~ 1.0.8已修复