Advanced Topics
This page covers advanced Infinity Plugin features including UI configuration, native view integration, scan switching, User Corrected Results (UCR), event caching, and platform-specific considerations.
UI Configuration
The Infinity Plugin offers two approaches to customizing the scan view UI: ScanView Config Options for simple, built-in controls and UI Feedback Config for advanced, fully customizable overlays.
| Prefer UI Feedback Config over ScanView Config Options whenever possible. It provides finer positioning control, uniform presentation across Android and iOS, and the ability to respond dynamically to scan feedback events. |
ScanView Config Options
scanViewConfigOptions provides a set of pre-built UI controls that can be added to the scan view with minimal configuration. These are passed as a top-level JSON property alongside the scan start request.
-
defaultOrientation
-
toolbarTitle
-
segmentConfig
Sets the initial screen orientation when the scan view is presented. Values: portrait or landscape.
{
"options": {
"defaultOrientation": "landscape"
}
}
Title shown on the toolbar with a back button. Fullscreen scanning only. Ignored when using a ContainerView (NativeView mode).
{
"options": {
"toolbarTitle": "Scan Document"
}
}
A multi-mode segment control for switching between different scanning configurations (e.g., MRZ, Barcode, License Plate). Requires equal numbers of titles and viewConfigs.
{
"options": {
"segmentConfig": {
"titles": ["MRZ", "Barcode", "License Plate"],
"viewConfigs": ["mrz_config.json", "barcode_config.json", "license_plate_config.json"],
"titleIndex": 0,
"tintColor": "0099FF"
}
}
}
The viewConfigs entries reference ScanViewConfig JSON files in the assets folder, resolved relative to the scanViewConfigPath set in the WrapperSessionScanStartRequest.
|
For all available options and their properties, see the WrapperSessionScanViewConfigOptions schema reference.
UI Feedback Config
For more advanced UI customization, use the UI Feedback Config system. This allows you to define interactive overlay elements (labels, images) that respond to scan state changes and user interaction.
Key advantages over ScanView Config Options:
-
Fine-grained positioning: precise control over element placement, sizing, and layering
-
Cross-platform consistency: uniform rendering on both Android and iOS
-
Scan feedback integration: elements can react dynamically to scan events (e.g. insufficient lighting, incorrect distance from object)
-
Interactive elements: tappable elements emit events via
onUIElementClicked
See UI Feedback Config for the full configuration guide, UIFeedback Config Elements for all available element types, and the UI Feedback Config schema reference.
Native View Integration
The Infinity Plugin supports two presentation modes for the scan view: full-screen and embedded (NativeView). Support varies by platform.
| Feature | Flutter | React Native | Cordova |
|---|---|---|---|
Full-screen scanning |
✓ |
✓ |
✓ |
Embedded NativeView |
✓ |
✓ |
✗ |
Full-Screen Mode
In full-screen mode, calling requestScanStart launches a native Activity (Android) or ViewController (iOS) that takes over the entire screen. This is the simplest integration and works on all platforms.
Embedded NativeView Mode (Flutter & React Native)
In NativeView mode, the scan view is embedded directly in the app’s widget/component tree. This allows you to display scanning alongside other UI elements (e.g., a results list) and control the view’s size and position.
-
Flutter
Use the AnylineNativeView widget to embed the scan view in your widget tree:
import 'package:anyline_plugin/anyline_native_view.dart';
class ScanScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: Container(
color: Colors.black,
child: const AnylineNativeView(),
),
),
// Add your custom UI elements here
],
);
}
}
Your MainActivity must extend FlutterFragmentActivity (not FlutterActivity) for NativeView support on Android.
|
Toggle between full-screen and NativeView mode at runtime. When AnylineNativeView is present in the widget tree, scanning renders inside it; otherwise, scanning opens full-screen.
Scan Switching
The Infinity Plugin supports switching scan modes without stopping and restarting the scan session.
Two methods are available:
-
requestScanSwitchWithScanStartRequestParams: switches using a fullWrapperSessionScanStartRequest, allowing you to change all scan parameters -
requestScanSwitchWithScanViewConfigContentString: switches using only a rawScanViewConfigJSON string, for simple configuration changes
Both methods are fire-and-forget: they do not return a response.
The correlationId parameter in scanViewInitializationParameters is an optional identifier you can set to group related scan operations in analytics and event exports.
-
Flutter
Switch to a new scan mode using a full scan-start request. For example, to change the scan configuration, save result images to a directory, and set a workflow correlationId:
import 'package:path_provider/path_provider.dart';
final appDir = await getApplicationDocumentsDirectory();
final resultPath = '${appDir.path}/results/';
// newScanViewConfigJson: a JSON string containing the replacement ScanViewConfig
final switchRequest = WrapperSessionScanStartRequest(
scanViewConfigContentString: newScanViewConfigJson,
scanResultConfig: WrapperSessionScanResultConfig(
cleanStrategy: WrapperSessionScanResultCleanStrategyConfig
.CLEAN_FOLDER_ON_START_SCANNING,
imageContainer: ExportedScanResultImageContainer(
saved: ExportedScanResultImageContainerSaved(
path: resultPath,
),
),
imageParameters: ExportedScanResultImageParameters(
quality: 50,
format: ExportedScanResultImageFormat.PNG,
),
),
scanViewInitializationParameters: ScanViewInitializationParameters(
correlationId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
),
);
await infinityPlugin.requestScanSwitchWithScanStartRequestParams(switchRequest);
Or switch using only a raw ScanViewConfig JSON string:
await infinityPlugin.requestScanSwitchWithScanViewConfigContentString(
newScanViewConfigJson,
);
User Corrected Results (UCR)
UCR allows you to submit corrections for scan results back to Anyline. This feedback loop helps improve scanning accuracy over time.
| UCR is opt-in, and you decide how it is implemented in your app. Additionally, your Anyline License Key needs to have the relevant flag enabled for UCR. Please contact your CSM or Support for further information. |
After receiving a scan result, you can present it to the user for verification. If the user corrects any fields, submit the corrected data via requestUCRReport. The request requires the blobKey from the original scan result, a unique identifier that links the correction to the specific scan event on the Anyline backend.
-
Flutter
// pluginResult: obtained from the onScanResults event stream (see Scan Result Handling)
// userCorrectedValue: the value corrected by the user after reviewing the scan result
final ucrRequest = WrapperSessionUcrReportRequest(
blobKey: pluginResult.blobKey,
correctedResult: userCorrectedValue,
);
try {
final ucrResponse = await infinityPlugin.requestUCRReport(ucrRequest);
if (ucrResponse.status == WrapperSessionUcrReportResponseStatus.UCR_REPORT_SUCCEEDED) {
print('UCR submitted: ${ucrResponse.succeedInfo?.message}');
} else {
print('UCR failed: ${ucrResponse.failInfo?.lastError}');
}
} on PlatformException catch (e) {
print('UCR report error: ${e.message}');
}
Exporting Cached Events
Your contact person at Anyline may request you to supply a log archive to track usage statistics. The Anyline Infinity Plugin provides the requestExportCachedEvents method to export cached scan events into a ZIP archive on the device filesystem. The method returns a response containing the filesystem path to the generated archive.
| Export of cached events ZIP generation can take up to several minutes depending on the number of recorded events. |
After exporting, retrieve the archive from the device and send it to your contact person at Anyline, as agreed to beforehand.
-
Flutter
try {
final exportResponse = await infinityPlugin.requestExportCachedEvents();
if (exportResponse.status == WrapperSessionExportCachedEventsResponseStatus.EXPORT_SUCCEEDED) {
final filePath = exportResponse.succeedInfo?.exportedFile;
print('Events exported to: $filePath');
} else {
print('Export failed: ${exportResponse.failInfo?.lastError}');
}
} on PlatformException catch (e) {
print('Event export error: ${e.message}');
}
Error Handling
All methods that interact with the native SDK can fail. Handle errors appropriately:
Flutter: Wrap await calls in try/catch blocks. Response objects include a failInfo property with error details when the operation does not succeed.
try {
final response = await infinityPlugin.requestScanStart(request);
if (response.failInfo != null) {
print('Scan ended with error: ${response.failInfo?.lastError}');
}
} catch (e) {
print('Scan start failed: $e');
}
Common error scenarios:
-
Invalid or expired license key
-
Camera permission not granted
-
Invalid
ScanViewConfigJSON -
Calling scan methods before SDK initialization
Next Steps
-
Schema Reference — configuration and result JSON schema reference
-
Infinity Plugin API Reference — complete method reference for the Infinity Plugin