Xamarin and Forms Deprecation Notice
Starting with version 8.0 we are no longer upgrading Xamarin and Forms solutions for the Data Capture SDK. Microsoft ended support for these frameworks on the 1st of May 2024, which locks them into discontinued tooling.
You may continue to use the latest releases of SDK version 7.x as per our support policy.
We recommend migrating to .NET MAUI to take advantage of the latest features and improvements in our SDK.
Advanced Configurations
Customization of the Overlays
To customize the appearance of an overlay you can implement a LabelCaptureBasicOverlayListener and/or LabelCaptureAdvancedOverlayListener interface, depending on the overlay(s) you are using.
The method brushForLabel() is called every time a label is captured, and brushForField() is called for each of its fields to determine the brush for the label or field.
using Scandit.DataCapture.Label.Capture;
using Scandit.DataCapture.Label.Data;
var overlay = LabelCaptureBasicOverlay.Create(labelCapture, dataCaptureView);
overlay.AddListener(new LabelCaptureBasicOverlayListener(
brushForLabel: (overlay, label) => {
return null;
},
brushForField: (overlay, field, label) => {
if (field.name == '<your-barcode-field-name>') {
return Brush(
fillColor: Colors.blue.withOpacity(0.2),
strokeColor: Colors.blue,
strokeWidth: 0,
);
}
if (field.name == '<your-expiry-date-field-name>') {
return Brush(
fillColor: Colors.red.withOpacity(0.2),
strokeColor: Colors.red,
strokeWidth: 0,
);
}
return null;
},
));
You can also use LabelCaptureBasicOverlay.setLabelBrush() and LabelCaptureBasicOverlay.setCapturedFieldBrush() to configure the overlay if you don't need to customize the appearance based on the name or content of the fields.
Advanced Overlay
For more advanced use cases, such as adding custom views or implementing Augmented Reality (AR) features, you can use the LabelCaptureAdvancedOverlay. The example below creates an advanced overlay, configuring it to display a styled warning message below expiry date fields when they’re close to expiring, while ignoring other fields.
using Scandit.DataCapture.Label.Capture;
using Scandit.DataCapture.Label.Data;
var overlay = LabelCaptureAdvancedOverlay.Create(labelCapture, dataCaptureView);
overlay.AddListener(new LabelCaptureAdvancedOverlayListener(
brushForLabel: (overlay, label) => {
return null;
},
brushForField: (overlay, field, label) => {
if (field.name == '<your-barcode-field-name>') {
return Brush(
fillColor: Colors.blue.withOpacity(0.2),
strokeColor: Colors.blue,
strokeWidth: 0,
);
}
if (field.name == '<your-expiry-date-field-name>') {
return Brush(
fillColor: Colors.red.withOpacity(0.2),
strokeColor: Colors.red,
strokeWidth: 0,
);
}
return null;
},
));
Validation Flow
Implementing a validation flow in your Smart Label Capture application differs from the Get Started steps outlined earlier as follows:
Visualize the Scan Process
Validation flow uses a different overlay, the LabelCaptureValidationFlowOverlay. This overlay provides a user interface that guides users through the label capture process, including validation steps.
var validationFlowOverlay = LabelCaptureValidationFlowOverlay.Create(
context,
labelCapture,
dataCaptureView
);
// Set the listener
validationFlowOverlay.AddListener(new MyValidationFlowListener());
Adjust the Hint Messages
var validationFlowOverlay = LabelCaptureValidationFlowOverlay.Create(
context,
labelCapture,
dataCaptureView
);
// Set the listener
validationFlowOverlay.AddListener(new MyValidationFlowListener());
Define a Listener
To handle validation events, implement the LabelCaptureValidationFlowOverlayListener interface.
var MyValidationFlowListener = new LabelCaptureValidationFlowOverlayListener(
onValidationFlowLabelCaptured: (fields) => {
String? barcodeData;
String? expiryDate;
for (final field in fields) {
if (field.name == "<your-barcode-field-name>") {
barcodeData = field.barcode?.data;
} else if (field.name == "<your-expiry-date-field-name>") {
expiryDate = field.text;
}
}
// Handle the captured values
}
);