scanWithCamera static method

Future<List<RecognizerResult>> scanWithCamera(
  1. RecognizerCollection collection,
  2. OverlaySettings overlaySettings,
  3. String license
)

Implementation

static Future<List<RecognizerResult>> scanWithCamera(RecognizerCollection collection, OverlaySettings overlaySettings, String license) async {
  var jsonResults = jsonDecode(await _channel.invokeMethod(
    METHOD_SCAN_WITH_CAMERA,
    {
      ARG_RECOGNIZER_COLLECTION: jsonDecode(jsonEncode(collection)),
      ARG_OVERLAY_SETTINGS: jsonDecode(jsonEncode(overlaySettings)),
      ARG_LICENSE: {
        ARG_LICENSE_KEY: license
      }
    })
  );

  if (jsonResults == null) return List.empty();

  var results = [];
  for (int i = 0; i < jsonResults.length; ++i) {
    var map = Map<String, dynamic>.from(jsonResults[i]);
    var result = collection.recognizerArray[i].createResultFromNative(map);
    if (result.resultState != RecognizerResultState.empty) {
      results.add(result);
    }
  }

  return List<RecognizerResult>.from(results);
}