processImageFromPath method

  1. @override
Future<OcrData?> processImageFromPath([
  1. String path = ""
])
override

Implementation

@override
Future<OcrData?> processImageFromPath([String path = ""]) async {
  bool validPath = await File.fromUri(Uri(path: path)).exists();
  if(!validPath) throw Exception("Invalid Image Path");

  // if(Platform.isAndroid) return null;
  String? ocrJson = await methodChannel.invokeMethod<String?>('processImageFromPath', {"path": path});
  if (ocrJson == null) return null;
  try {
    OcrData ocrData = OcrData.fromJson(jsonDecode(ocrJson));
    return ocrData;
  } catch (e) {
    return null;
  }
}