listenPhysicalButton static method

Stream<CameraPhysicalButton>? listenPhysicalButton()

Implementation

static Stream<CameraPhysicalButton>? listenPhysicalButton() {
  _physicalButtonStream ??= _physicalButtonChannel
      .receiveBroadcastStream('physicalButtonChannel')
      .transform(
          StreamTransformer<dynamic, CameraPhysicalButton>.fromHandlers(
              handleData: (data, sink) {
    CameraPhysicalButton? physicalButton;
    switch (data) {
      case 'VOLUME_UP':
        physicalButton = CameraPhysicalButton.volume_up;
        break;
      case 'VOLUME_DOWN':
        physicalButton = CameraPhysicalButton.volume_down;
        break;
      default:
    }
    sink.add(physicalButton!);
  }));
  return _physicalButtonStream;
}