start method

Future<PreviewDetails>? start({
  1. required int width,
  2. required int height,
  3. required QRCodeHandler qrCodeHandler,
  4. List<Symbology>? formats = const [Symbology.QR],
  5. bool camera2Enabled = false,
})

Implementation

Future<PreviewDetails>? start({
  required int width,
  required int height,
  required QRCodeHandler qrCodeHandler,
  List<Symbology>? formats = const [Symbology.QR],
  bool camera2Enabled = false,
}) async {
  _channelReader.setQrCodeHandler(qrCodeHandler);
  var details =
      await _channel.invokeMethod(MethodConst.nativeStartCapturing, {
    Param.targetWidth: width,
    Param.targetHeight: height,
    Param.heartbeatTimeout: 0,
    Param.formats: formats?.map((e) => e.stringify).toList(),
    Param.camera2Enabled: camera2Enabled,
  });

  int? textureId = details[Param.textureId];
  num? orientation = details[Param.surfaceOrientation];
  num? surfaceHeight = details[Param.surfaceHeight];
  num? surfaceWidth = details[Param.surfaceWidth];

  return PreviewDetails(
    surfaceWidth,
    surfaceHeight,
    orientation,
    textureId,
  );
}