# FlutterStreamHandler

Objective-C

    @protocol FlutterStreamHandler

Swift

    protocol FlutterStreamHandler

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

- `-onListenWithArguments:eventSink:`

  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;

  Swift

      func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError?

  #### 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.

- `-onCancelWithArguments:`

  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;

  Swift

      func onCancel(withArguments arguments: Any?) -> FlutterError?

  #### Parameters

  `arguments` | Arguments for the stream.

  #### Return Value

  A FlutterError instance, if teardown fails.

© 2023 Flutter. All rights reserved. (Last updated: 2023-05-23)

Generated by jazzy ♪♫ v0.14.3, a Realm project.