load method
Opens the WebAssembly opus library contained in this plugin and injects the JavaScript glue if necessary.
Registers the memory of the created web_ffi DynamicLibrary
as Memory.global
if there is no global memory yet.
Implementation
Future<dynamic> load() async {
if (!_injected) {
await InjectJs.importLibrary(
'./assets/packages/opus_flutter_web/assets/libopus.js');
_injected = true;
}
if (_module == null) {
Memory.init();
ByteData wasmBinary = await rootBundle
.load('packages/opus_flutter_web/assets/libopus.wasm');
_module = await EmscriptenModule.compile(
wasmBinary.buffer
.asUint8List(wasmBinary.offsetInBytes, wasmBinary.lengthInBytes),
'libopus');
}
return new DynamicLibrary.fromModule(_module!);
}