0
votes
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')),
    ]);
  }

I am new to flutter, for my applications i want play two sounds mode(background sound ,button action sound), after referred from flutter package i have changed code like as above , when i used this widget in my material,i am getting below error,

E/flutter ( 2750): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception: E/flutter ( 2750): Unable to load asset: assets/assetsImagesMP3.mp3 E/flutter ( 2750): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)

1

1 Answers

0
votes

Backslash are Windows-specific. Use slashes instead. Android is Unix-based and so is iOS

audioCache.play('assets/Images/MP3.mp3')