pubspec.yaml
flutter:
uses-material-design: true
assets:
- assets/Images/1.png
- assets/Images/MP3.mp3
Test.dart
Widget localAsset() {
return _tab([
Text("Click to play"),
_btn('Play', () => audioCache.play('assets\Images\MP3.mp3')),
]);
}
我是flutter的新手,对于我的应用程序,我想播放两种声音模式(背景声音,按钮动作声音),在flutter包中引用后,我已经像上面那样更改了代码,当我在材质中使用此小部件时,i低于错误,
E / flutter(2750):[错误:flutter / shell / common / shell.cc(181)] Dart错误:未处理的异常: E / flutter(2750):无法加载资产:assets / assetsImagesMP3.mp3 E / flutter(2750):#0 PlatformAssetBundle.load(package:flutter / src / services / asset_bundle.dart:221:7)
答案 0 :(得分:0)
反斜杠特定于Windows。改用斜杠。 Android是基于Unix的,iOS也是如此
audioCache.play('assets/Images/MP3.mp3')