Soundpool? pool;
int? soundId;
...
if (!UniversalPlatform.isAndroid) return;
pool = Soundpool.fromOptions(
options: const SoundpoolOptions(
streamType: StreamType.notification,
),
);
final soundData = await rootBundle.load('assets/[redacted].wav');
soundId = await pool!.load(soundData);
// ... later in a function call
if (!UniversalPlatform.isAndroid) return;
if (pool == null || soundId == null) return;
await pool!.play(soundId!);
PlatformException(error, Index: 0, Size: 0, null, java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at wc.b.onMethodCall(SoundpoolPlugin.kt:23)
at da.j$a.a(MethodChannel.java:2)
at q9.c.l(DartMessenger.java:2)
at q9.c.m(DartMessenger.java:2)
at q9.c.i(Unknown Source:0)
at q9.b.run(Unknown Source:12)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7078)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
)
File "message_codecs.dart", line 653, in StandardMethodCodec.decodeEnvelope
File "platform_channel.dart", line 296, in MethodChannel._invokeMethod
File "<asynchronous suspension>"
File "method_channel_soundpool_platform.dart", line 26, in MethodChannelSoundpoolPlatform.play
File "<asynchronous suspension>"
File "soundpool.dart", line 193, in Soundpool.play
File "<asynchronous suspension>"