recognize method

Performs a recognition of the text written on screen. It takes an instance of Ink which refers to the user input as a list of Stroke.

Implementation

Future<List<RecognitionCandidate>> recognize(Ink ink,
    {DigitalInkRecognitionContext? context}) async {
  final result = await _channel
      .invokeMethod('vision#startDigitalInkRecognizer', <String, dynamic>{
    'id': id,
    'ink': ink.toJson(),
    'context': context?._isValid == true ? context?.toJson() : null,
    'model': languageCode,
  });

  final List<RecognitionCandidate> candidates = <RecognitionCandidate>[];
  for (final dynamic json in result) {
    final candidate = RecognitionCandidate.fromJson(json);
    candidates.add(candidate);
  }

  return candidates;
}