FlutterStreamHandler

@protocol FlutterStreamHandler

A strategy for exposing an event stream to the Flutter side.

  • Sets up an event stream and begin emitting events.

    Invoked when the first listener is registered with the Stream associated to this channel on the Flutter side.

    Declaration

    Objective-C

    - (FlutterError *_Nullable)onListenWithArguments:(id _Nullable)arguments
                                           eventSink:
                                               (nonnull FlutterEventSink)events;

    Parameters

    arguments

    Arguments for the stream.

    events

    A callback to asynchronously emit events. Invoke the callback with a FlutterError to emit an error event. Invoke the callback with FlutterEndOfEventStream to indicate that no more events will be emitted. Any other value, including nil are emitted as successful events.

    Return Value

    A FlutterError instance, if setup fails.

  • Tears down an event stream.

    Invoked when the last listener is deregistered from the Stream associated to this channel on the Flutter side.

    The channel implementation may call this method with nil arguments to separate a pair of two consecutive set up requests. Such request pairs may occur during Flutter hot restart.

    Declaration

    Objective-C

    - (FlutterError *_Nullable)onCancelWithArguments:(id _Nullable)arguments;

    Parameters

    arguments

    Arguments for the stream.

    Return Value

    A FlutterError instance, if teardown fails.