import 'package:flutter/material.dart'; import 'package:flutter_scalable_ocr/flutter_scalable_ocr.dart'; import 'package:get/get.dart'; import '../../../controller/functions/ocr_controller.dart'; class TextScanner extends StatelessWidget { TextScanner({super.key}); final OCRController controller = Get.put(OCRController()); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Flutter Scalable OCR'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ ScalableOCR( paintboxCustom: Paint() ..style = PaintingStyle.stroke ..strokeWidth = 4.0 ..color = const Color.fromARGB(153, 102, 160, 241), boxLeftOff: 5, boxBottomOff: 2.5, boxRightOff: 5, boxTopOff: 2.5, boxHeight: MediaQuery.of(context).size.height / 3, getRawData: (value) { // Inspect the raw data here. }, getScannedText: (value) { controller.setText(value); }), Result(), Obx(() { return SnackBar( content: Text(controller.text.value), ); }) ], ), )); } } class Result extends StatelessWidget { Result({ Key? key, }) : super(key: key); final OCRController controller = Get.find(); @override Widget build(BuildContext context) { return Text("Readed text: ${controller.text.value}"); } } class TextExtractionView extends StatelessWidget { TextExtractionView({super.key}); @override Widget build(BuildContext context) { Get.put(TextExtractionController()); return Scaffold( appBar: AppBar( title: const Text('Text Extraction'), ), body: GetBuilder(builder: (controller) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: () => controller.pickAndExtractText(), child: const Text('Pick Image and Extract Text'), ), const SizedBox(height: 20), Text(controller.extractedText), ], ), ); }), ); } } // import 'package:flutter/material.dart'; // import 'package:get/get.dart'; // import 'package:image_picker/image_picker.dart'; // // import '../../../controller/functions/document_scanner.dart'; // // class TextScanner extends StatelessWidget { // // final ImagePickerController _imagePickerController = // // Get.put(ImagePickerController()); // // TextScanner({super.key}); // // @override // Widget build(BuildContext context) { // return Scaffold( // appBar: AppBar( // title: const Text('Image Picker'), // ), // body: Center( // child: Column( // mainAxisAlignment: MainAxisAlignment.center, // children: [ // Obx(() { // // final bool textScanning = // // _imagePickerController.textScanning.value; // // final String scannedText = // // _imagePickerController.scannedText.value; // // if (textScanning) { // return const CircularProgressIndicator(); // } else if (scannedText.isNotEmpty) { // return Text(scannedText); // } else { // return const Text('No text scanned'); // } // }), // ElevatedButton( // onPressed: () => // _imagePickerController.getImage(ImageSource.camera), // child: const Text('Take Picture'), // ), // ], // ), // ), // ); // } // }