import 'package:cpd_app/http_utils.dart'; import 'package:cpd_app/image_uploader.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class OCRPage extends StatefulWidget { const OCRPage({super.key}); @override State createState() => _OCRPageState(); } class _OCRPageState extends State { String _extractedText = ''; final ImageUploader _imageUploader = ImageUploader(); final HttpUtils _httpUtils = HttpUtils(); @override void initState() { super.initState(); uploadImage("lorem.png"); } Future uploadImage(String img) async { //hier wird der user sein bild auswählen können //aktuell hardcoded bild zum testen String imageName = img; Uint8List imageBytes = await _imageUploader.buildImageFile(imageName); String lang = await _httpUtils.performHttpRequest(imageBytes, imageName); String text = await _imageUploader.performOcr(imageBytes, imageName, lang); setState(() { _extractedText = text; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('OCR'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: () => uploadImage("lorem.png"), child: const Text('Test Upload Image'), ), Text(_extractedText), TextButton( onPressed: () { Clipboard.setData(ClipboardData(text: _extractedText)); }, child: const Text('Copy to Clipboard'), ), ], ), ), ); } }