Skip to content

Migration Guide: From 6.x To 7.x

From v6.9 To v7.1

The Flutter plugin has been completely reworked in release 7.1, so public interfaces were changed as well. This section provides the side-by-side comparison of the basic features between releases 6.9 and 7.1.

Accessing DocumentReader

DocumentReader.
DocumentReader.instance.

var documentReader = DocumentReader.instance;
documentReader.

Preparing Database

const EventChannel('flutter_document_reader_api/event/database_progress')
    .receiveBroadcastStream()
    .listen((progress) => showProgress(progress));

await DocumentReader.prepareDatabase("Full");

onDatabasePrepared();
await DocumentReader.instance.prepareDatabase("Full", showProgress);

onDatabasePrepared();

Initializing

String licenseBase64 = base64.encode(license);

await DocumentReader.initializeReader({
"license": licenseBase64,
"delayedNNLoad": true
});

onInitialized();
var initConfig = DocReaderConfig(license);
initConfig.delayedNNLoad = true;

await DocumentReader.instance.initializeReader(initConfig);

onInitialized();

Accessing Fields

bool canRfid = await DocumentReader.isRFIDAvailableForUse();
bool canRfid = DocumentReader.instance.isRFIDAvailableForUse;

Accessing Available Scenarios

var scenariosString = await DocumentReader.getAvailableScenarios();
var scenariosJson = json.decode(scenariosString);
List<DocumentReaderScenario> scenarios = [];

for (var i = 0; i < scenariosJson.length; i++) {
var scenarioJson = scenariosJson[i];
if(scenarioJson is String){
    scenarioJson = json.decode(scenarioJson);
}
DocumentReaderScenario scenario = DocumentReaderScenario.fromJson(scenarioJson)!;
scenarios.add(scenario);
}
List<DocumentReaderScenario> scenarios = DocumentReader.instance.availableScenarios;

Changing Configuration

DocumentReader.setConfig({
"functionality": {
    "videoCaptureMotionControl": true,
    "showCaptureButton": true
},
"customization": {
    "showResultStatusMessages": true,
    "showStatusMessages": true
},
"processParams": {"alreadyCropped": false}
});
var functionality = DocumentReader.instance.functionality;
functionality.videoCaptureMotionControl = true;
functionality.showCaptureButton = true;

var customization = DocumentReader.instance.customization;
customization.showResultStatusMessages = true;
customization.showStatusMessages = true;

DocumentReader.instance.processParams.alreadyCropped = false;

Scanning Document

const EventChannel('flutter_document_reader_api/event/completion')
    .receiveBroadcastStream()
    .listen((completionString) {
var completionJson = json.decode(completionString);
DocumentReaderCompletion completion = DocumentReaderCompletion.fromJson(completionJson)!;

int action = completion.action!;
DocumentReaderResults? results = completion.results;
RegulaException? error = completion.error;

handleCompletion(action, results, error);
});

var config = ScannerConfig();
config.scenario = "Mrz";
DocumentReader.scan(config.toJson());
var config = ScannerConfig.withScenario(Scenario.MRZ);
documentReader.scan(config, handleCompletion);

Reading RFID

const EventChannel('flutter_document_reader_api/event/completion')
    .receiveBroadcastStream()
    .listen((completionString) {
var completionJson = json.decode(completionString);
DocumentReaderCompletion completion = DocumentReaderCompletion.fromJson(completionJson)!;

int action = completion.action!;
DocumentReaderResults? results = completion.results;
RegulaException? error = completion.error;

handleCompletion(action, results, error);
});

DocumentReader.startRFIDReader();
var config = RFIDConfig(handleCompletion);
DocumentReader.instance.rfid(config);

Additional Resources