48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
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'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|