handler property
Sets the handler that is invoked for every incoming message.
The handler is invoked in the Zone.root zone. If the handler should be invoked in the current zone, do:
rawPort.handler = Zone.current.bind(actualHandler);
The handler must be a function which can accept one argument of the type of the messages sent to this port. This means that if it is known that messages will all be Strings, a handler of type void Function(String)
can be used. The function is invoked dynamically with the actual messages, and if this invocation fails, the error becomes a top-level uncaught error in the Zone.root zone.
Implementation
// TODO(44659): Change parameter type to `void Function(Never)` to only // accept functions which can be called with one argument. void set handler(Function? newHandler);
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-isolate/RawReceivePort/handler.html