start static method
Future<PreviewDetails>
start({
- required int width,
- required int height,
- required QRCodeHandler qrCodeHandler,
- List<
BarcodeFormats> ? formats = _defaultBarcodeFormats,
Implementation
static Future<PreviewDetails> start({
required int width,
required int height,
required QRCodeHandler qrCodeHandler,
List<BarcodeFormats>? formats = _defaultBarcodeFormats,
}) async {
final _formats = formats ?? _defaultBarcodeFormats;
assert(_formats.length > 0);
List<String> formatStrings = _formats
.map((format) => format.toString().split('.')[1])
.toList(growable: false);
channelReader.setQrCodeHandler(qrCodeHandler);
var details = await _channel.invokeMethod('start', {
'targetWidth': width,
'targetHeight': height,
'heartbeatTimeout': 0,
'formats': formatStrings,
});
// invokeMethod returns Map<dynamic,...> in dart 2.0
assert(details is Map<dynamic, dynamic>);
int? textureId = details["textureId"];
num? orientation = details["surfaceOrientation"];
num? surfaceHeight = details["surfaceHeight"];
num? surfaceWidth = details["surfaceWidth"];
return PreviewDetails(surfaceWidth, surfaceHeight, orientation, textureId);
}