dispose method
Disposes the controller and releases associated resources.
This method should be called when the controller is no longer needed to prevent memory leaks. After calling this method, the controller cannot be used for any operations.
It's safe to call this method multiple times.
Example:
@override
void dispose() {
controller.dispose();
super.dispose();
}
Implementation
Future<void> dispose() async {
try {
await _channel?.invokeMethod('dispose');
} catch (e) {
// Ignore disposal errors
} finally {
_channel?.setMethodCallHandler(null);
_channel = null;
}
}