initPhysicalButton method

void initPhysicalButton()

Implementation

void initPhysicalButton() {
  _physicalButtonStreamSub?.cancel();
  _physicalButtonStreamSub =
      CamerawesomePlugin.listenPhysicalButton()!.listen(
    (res) async {
      if (res == CameraPhysicalButton.volume_down ||
          res == CameraPhysicalButton.volume_up) {
        cameraContext.state.when(
          onPhotoMode: (pm) => pm.takePhoto(),
          onVideoMode: (vm) => vm.startRecording(),
          onVideoRecordingMode: (vrm) => vrm.stopRecording(),
        );
      }
    },
  );
}