takePicture method

Future<void> takePicture({
  1. ShutterCallback? shutter,
  2. PictureCallback? raw,
  3. PictureCallback? postView,
  4. PictureCallback? jpeg,
})

Triggers an asynchronous image capture.

The camera service will initiate a series of callbacks to the application as the image capture progresses. The shutter callback occurs after the image is captured. This can be used to trigger a sound to let the user know that image has been captured. The raw callback occurs when the raw image data is available (NOTE: the data will be null if there is no raw image callback buffer available or the raw image callback buffer is not large enough to hold the raw image). The postview callback occurs when a scaled, fully processed postview image is available (NOTE: not all hardware supports this). The jpeg callback occurs when the compressed image is available. If the application does not need a particular callback, a null can be passed instead of a callback method.

This method is only valid when preview is active (after startPreview). Preview will be stopped after the image is taken; callers must call startPreview again if they want to re-start preview or take more pictures. This should not be called between MediaRecorder.start and MediaRecorder.stop.

After calling this method, you must not call startPreview or take another picture until the JPEG callback has returned.

shutter: the callback for image capture moment, or null raw: the callback for raw (uncompressed) image data, or null postview: callback with postview image data, may be null jpeg: the callback for JPEG image data, or null

Throws PlatformException if starting picture capture fails; usually this would be because of a hardware or other low-level error, or because release has been called on this Camera instance.

Implementation

Future<void> takePicture({
  ShutterCallback? shutter,
  PictureCallback? raw,
  PictureCallback? postView,
  PictureCallback? jpeg,
}) {
  if (shutter != null) {
    ChannelRegistrar.instance.implementations.channelShutterCallback.$$create(
      shutter,
      $owner: false,
    );
  }
  return _channel.$takePicture(
    this,
    shutter,
    raw,
    postView,
    jpeg,
  );
}