readText method

Future<List<RecognitionCandidate>> readText(
  1. List<Offset?> points,
  2. String modelTag
)

Function that invokes the method to read the text written on screen. It takes modelTag that refers to language that is being processed. Note that modelTag should follow BCP 47 guidelines of identifying language visit this site https://tools.ietf.org/html/bcp47 to know more. It takes List<Offset> which refers to the points being written on screen.

Implementation

Future<List<RecognitionCandidate>> readText(
    List<Offset?> points, String modelTag) async {
  _isOpened = true;
  List<Map<String, dynamic>> pointsList = <Map<String, dynamic>>[];
  for (var point in points) {
    if (point != null) {
      pointsList.add(<String, dynamic>{'x': point.dx, 'y': point.dy});
    }
  }
  final result = await Vision.channel.invokeMethod(
      'vision#startDigitalInkRecognizer',
      <String, dynamic>{'points': pointsList, 'modelTag': modelTag});

  final List<RecognitionCandidate> candidates = <RecognitionCandidate>[];
  for (final dynamic data in result) {
    final candidate = RecognitionCandidate(data["text"], data["score"]);
    candidates.add(candidate);
  }

  _isClosed = false;
  return candidates;
}