提问人:levi 提问时间:5/25/2023 更新时间:11/3/2023 访问量:274
Flutter Model Viewer 不显示任何内容
Flutter Model Viewer doesn't display anything
问:
我正在尝试使用 flutter 的模型查看器加 (https://pub.dev/packages/model_viewer_plus) 并且我已经集成了它,但 ModelViewer 没有显示在我的应用程序中。屏幕工作正常,但根本不显示模型。我试图将模型直接放在屏幕文件甚至资产文件夹中,但似乎没有任何效果(也尝试了在线模型 url,但仍然不起作用)。
这是我的屏幕文件
import 'package:flutter/material.dart';
import 'package:model_viewer_plus/model_viewer_plus.dart';
class PlaceModel extends StatelessWidget {
const PlaceModel({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("Model Viewer")),
body: ModelViewer(
backgroundColor: Colors.teal,
src: "E:\\BuildVisionFYP\\build_vision_fyp\\public\\models\\Duck.glb",
alt: "A 3D model of an astronaut",
ar: true,
autoRotate: true,
cameraControls: true,
),
),
);
}
}
这是我的pubspec.yaml
name: build_vision_fyp
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=3.0.1 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
flutter_svg: ^2.0.5
animations: ^2.0.7
flutter_archive: ^5.0.0
path_provider: ^2.0.15
model_viewer_plus: ^1.5.0
http: ^0.13.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
assets:
- assets/images/
- assets/icons/
- assets/models/
- public/models/
我也附上了屏幕的屏幕截图 截图
我也在日志中得到这个:
HTML generated for model_viewer_plus:
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body,
model-viewer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
/* other-css */
</style>
<model-viewer src="E:\BuildVisionFYP\build_vision_fyp\public\models\Duck.glb" alt="A 3D model of an astronaut" ar camera-controls auto-rotate style="background-color: rgba(0, 150, 136, 255); ">
</model-viewer>
请帮忙谢谢
答:
0赞
kunal20
11/3/2023
#1
使用正斜杠
“E:/BuildVisionFYP/build_vision_fyp/public/models/Duck.glb”
的
“E:\\BuildVisionFYP\\build_vision_fyp\\public\\models\\Duck.glb”
以找到文件。
评论