Libserialport_flutter exception handling

Hello everyone. I use the libserialport library in my program (Linux).
There was a question, the answer to which I cannot find anywhere. I use a usb connection of the serial port. When the connection is broken (for example, I disconnect the serial port from USB) the program does not stop, but in the VSCode console I see an exception:[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SerialPortError: I / O error, errno = 5

Please tell me how can I handle this exception in my program? How to catch it?