takePicture method

  1. @override
Future<void> takePicture(
  1. ImageCallback callback
)
override

Take a picture and return the bytes in callback.

The default output is for a JPEG image.

This should only be called after passing as a parameter to a CameraController and CameraController.initialize has been called.

Implementation

@override
Future<void> takePicture(intf.ImageCallback callback) {
  verifyAttached();
  return _controller.camera.takePicture(
    jpeg: PictureCallback((Uint8List? bytes) {
      _controller.camera.startPreview();
      // This default implementations of this output should always return a
      // byte array. If the settings of this output is overriden, this could
      // return a null value.
      callback(bytes!);
    }),
  );
}