dispose method

Future<void> dispose()

Manually disposes of a previously retained native player instance.

⚠️ Use with caution.

This should be used in conjunction with keepAlive when you've explicitly retained a player beyond the view's lifetime. It ensures the native resources are released when no longer needed.

If you haven't used keepAlive, you typically do not need to call this method, as ImpulsePlayer automatically disposes of resources during normal lifecycle cleanup.

Note: This API is likely to be removed in a future version, once full media control lifecycle management is implemented in the plugin.

Implementation

Future<void> dispose() async {
  final id = await ImpulsePlayerFactory.getViewId(this);
  return ImpulsePlayerPluginPlatform.instance.dispose(id);
}