import 'dart:io'; import 'package:flutter/services.dart'; import 'ocr_backend.dart'; /// Platform OCR backend. Uses the Windows built-in OCR engine exposed through /// the native `badnote/ocr` MethodChannel. class NativeOcrBackend implements OcrBackend { static const _channel = MethodChannel('badnote/ocr'); @override String get name => 'native'; @override Future isAvailable() async => Platform.isWindows; @override Future recognize(Uint8List pngBytes) async { if (!Platform.isWindows) return null; try { final result = await _channel.invokeMethod('recognize', pngBytes); final text = result?.trim(); if (text == null || text.isEmpty) return null; return text; } catch (_) { return null; } } }