[英]Which Flutter plugin or feature can utilize an external iOS/Android display showing separate content from the main display
I am building a cross-platform app which needs to show a different view on an external display (usually connected via an HDMI adapter cable connected to a LCD projector.) Does Flutter have the ability to display a different screen on an external display either built-in or with an existing Flutter plugin?我正在构建一个跨平台应用程序,它需要在外部显示器上显示不同的视图(通常通过连接到 LCD 投影仪的 HDMI 适配器电缆连接。) Flutter 是否能够在外部显示器上显示不同的屏幕- 在或使用现有的 Flutter 插件? I would not want to write a bridge or plugin myself, as it would require native Swift ( UIScreen ) and Kotlin ( Presentation class ) code.
我不想自己编写桥接器或插件,因为它需要本机 Swift ( UIScreen ) 和 Kotlin ( Presentation class ) 代码。
As I am exploring different cross-platform frameworks for iOS and Android I only found React Native with a usable package: React Native External Display - A React Native view renderer in External Display .当我正在探索 iOS 和 Android 的不同跨平台框架时,我只发现 React Native 带有可用的 packageer: React Native Display External Display - A React Native 视图渲染。
Is there anything similar available for Flutter or what would be the best way to approach this in Flutter? Flutter 是否有类似的东西,或者在 Flutter 中解决这个问题的最佳方法是什么?
You can try the presentation_displays
.你可以试试
presentation_displays
。 It supports running the app in 2 displays with independent images, not mirroring.它支持在具有独立图像的 2 个显示器中运行应用程序,而不是镜像。
Flutter plugin supports to run on two screens. Flutter 插件支持在两个屏幕上运行。 It's basically a tablet connected to another screen via an HDMI or Wireless
它基本上是通过 HDMI 或无线连接到另一个屏幕的平板电脑
Idea : We create a Widget by using Flutter code and pass it to Native code side then convert it to FlutterEngine and save it to FlutterEngineCache for later use.思路:我们使用 Flutter 代码创建一个 Widget 并将其传递给 Native 代码端,然后将其转换为 FlutterEngine 并保存到 FlutterEngineCache 以备后用。
Next, we define the Display by using displayId and we will define the UI flutter that needs to display by grabbing FlutterEngine in FlutterEngineCache and transferring it to Dialog Presentation as a View.接下来,我们使用 displayId 定义 Display,我们将通过抓取 FlutterEngineCache 中的 FlutterEngine 并将其作为 View 传输到 Dialog Presentation 来定义需要显示的 UI flutter。
We provide methods to get a list of connected devices and the information of each device then transfer data from the main display to the secondary display.我们提供了获取连接设备列表和每个设备信息的方法,然后将数据从主显示器传输到辅助显示器。
Simple steps:简单的步骤:
Create Widgets that need to display and define them as a permanent router when you configure the router in the Flutter code.在 Flutter 代码中配置路由器时,创建需要显示的 Widgets 并将其定义为永久路由器。
Get the Displays list by calling displayManager.getDisplays ()
通过调用
displayManager.getDisplays ()
获取Displays列表
Define which Display needs to display For instance: displays 1 .displayId
Display the index 2.定义需要显示哪个Display 例如:displays 1
.displayId
显示索引2。
Display it on Display with your routerName as presentation displayManager.showSecondaryDisplay (displayId: displays [1].displayId, routerName: "presentation")
将它显示在 Display 上,您的 routerName 作为演示文稿
displayManager.showSecondaryDisplay (displayId: displays [1].displayId, routerName: "presentation")
Transmit the data from the main display to the secondary display by displayManager.transferDataToPresentation (" test transfer data ")
通过
displayManager.transferDataToPresentation (" test transfer data ")
将数据从主显传输到副显
The secondary screen receives data副屏接收数据
@override
Widget build (BuildContext context) {
return SecondaryDisplay (
callback: (argument) {
setState (() {
value = argument;
});
}
);
}
Note: Extracted from Github page.注:摘自 Github 页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.