在叠加小部件中渲染模型查看器小部件时出错

Error while rendering model viewer widget inside overlay widget

提问人:Arvind suresh 提问时间:8/12/2023 更新时间:8/12/2023 访问量:22

问:

我正在尝试使用 flutter_overlay_window modelviewer_plus 0.4.3 在叠加窗口中使用包显示 3d 模型,当我在单独的页面中显示它时,它呈现得很完美,但是当我尝试在叠加窗口中显示它时,它会抛出错误 libcolorx-loader.so 的文件路径无效 这就是我实现项目的方式。 在主文件中:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initAppService();
  runApp(const MyApp());
}

@pragma("vm:entry-point")
void overlayMain() {
  runApp(const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyOverlayContent()
  ));
}

MyApp() 将主页作为主页小部件运行,这就是我在主页中调用覆盖的方式:

Column(
        children: [
          ElevatedButton(onPressed: () async {
            await FlutterOverlayWindow.showOverlay(height: 600,width: 600,enableDrag: true);
          }, child: Text("start overlay")),
          ElevatedButton(onPressed: () async {
            status = await FlutterOverlayWindow.requestPermission();
            if(!status!)
              await FlutterOverlayWindow.requestPermission();
          }, child: Text("request permission")),

这是 MyOverlayContent() 页面代码:

class _MyOverlayContentState extends State<MyOverlayContent> {
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 300,
      color: Colors.deepOrange,
      child: ListView(
          children: [
            SizedBox(
              height: 100,
            ),
            Container(
              color: Colors.blue,
              height: 100,
              child: const ModelViewer(
                animationName: 'Taunt',
                backgroundColor: Colors.transparent,
                src: 'assets/DamagedHelmet.glb', // a bundled asset file
                alt: "A 3D model of an astronaut",
                ar: true,
                autoPlay: true,
                animationCrossfadeDuration: 400,
                arModes: ["webxr", "scene-viewer"],
                autoRotate: false,
                cameraControls: true,
                disableZoom: false,
              ),
            ),
            ElevatedButton(onPressed: () async {
              await FlutterOverlayWindow.closeOverlay();
            }, child: Text("start background service "))
          ],
        ),
    );
  }
}

有人可以指定我做错了什么,提前致谢!

Android Flutter 3D 叠加 模型查看

评论


答: 暂无答案