10/20/1
This commit is contained in:
@@ -7,7 +7,9 @@ class AppCredintials {
|
||||
'AAAAinYllCo:APA91bF1shTpzSsSxqbfY6c60D8zs1ZsdIsl9ix6nl7GDdjCqWPRK0G0ub5SqFdb1jDpQDvQPxGg-697MWLo0sy3oYImBwBLObyhk0GjtNzyr0PbE3hI-pOvhf8Vp1xgUgBmofbZYXkH';
|
||||
// AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0
|
||||
static const String mapAPIKEY = 'AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0';
|
||||
|
||||
static const String twilloRecoveryCode = 'TQF13XUVU2NJ3VFU8JWBWYBS';
|
||||
static const String accountSIDTwillo = 'ACb4ad857efe0903bfd6238a763a2ce4d1';
|
||||
static const String authTokenTwillo = '14f39ef4628bb8a4f18469f462f8af75';
|
||||
String getBasicAuthCredentials() {
|
||||
return base64Encode(utf8.encode(basicAuthCredentials));
|
||||
}
|
||||
|
||||
37
lib/controller/firebase/ml_kit.dart
Normal file
37
lib/controller/firebase/ml_kit.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:google_ml_kit/google_ml_kit.dart';
|
||||
|
||||
class TextRecognizerController extends GetxController {
|
||||
// The ImagePicker instance
|
||||
final ImagePicker _imagePicker = ImagePicker();
|
||||
|
||||
// The GoogleMlKit TextRecognizer instance
|
||||
final TextRecognizer _textRecognizer = TextRecognizer();
|
||||
|
||||
// The scanned text
|
||||
String? scannedText;
|
||||
|
||||
// Picks an image from the camera or gallery and extracts the text
|
||||
Future<void> scanText() async {
|
||||
// Pick an image from the camera or gallery
|
||||
final XFile? image =
|
||||
await _imagePicker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
// If no image was picked, return
|
||||
if (image == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Recognize the text in the image
|
||||
final RecognizedText recognizedText =
|
||||
await _textRecognizer.processImage(image as InputImage);
|
||||
|
||||
// Extract the scanned text
|
||||
scannedText = recognizedText.text;
|
||||
|
||||
// Update the UI
|
||||
update();
|
||||
}
|
||||
}
|
||||
69
lib/controller/functions/device_info.dart
Normal file
69
lib/controller/functions/device_info.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
class DeviceInfoPlus {
|
||||
static Future<Map<String, dynamic>> getDeviceInfo() async {
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
Map<String, dynamic> deviceData = {};
|
||||
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceData['platform'] = 'Android';
|
||||
deviceData['brand'] = androidInfo.brand;
|
||||
deviceData['model'] = androidInfo.model;
|
||||
deviceData['androidId'] = androidInfo.device;
|
||||
deviceData['version'] = androidInfo.version.release;
|
||||
deviceData['sdkVersion'] = androidInfo.version.sdkInt;
|
||||
deviceData['manufacturer'] = androidInfo.manufacturer;
|
||||
deviceData['isPhysicalDevice'] = androidInfo.isPhysicalDevice;
|
||||
deviceData['serialNumber'] = androidInfo.serialNumber;
|
||||
deviceData['fingerprint'] = androidInfo.fingerprint;
|
||||
deviceData['type'] = androidInfo.type;
|
||||
deviceData['data'] = androidInfo.data;
|
||||
deviceData['version'] = androidInfo.version;
|
||||
deviceData['tags'] = androidInfo.tags;
|
||||
deviceData['display'] = androidInfo.display;
|
||||
} else if (Platform.isIOS) {
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
deviceData['brand'] = 'Apple';
|
||||
deviceData['model'] = iosInfo.model;
|
||||
deviceData['systemName'] = iosInfo.systemName;
|
||||
deviceData['systemVersion'] = iosInfo.systemVersion;
|
||||
deviceData['utsname'] = iosInfo.utsname;
|
||||
deviceData['isPhysicalDevice'] = iosInfo.isPhysicalDevice;
|
||||
deviceData['identifierForVendor'] = iosInfo.identifierForVendor;
|
||||
deviceData['name'] = iosInfo.name;
|
||||
deviceData['localizedModel'] = iosInfo.localizedModel;
|
||||
} else if (Platform.isMacOS) {
|
||||
MacOsDeviceInfo macInfo = await deviceInfoPlugin.macOsInfo;
|
||||
deviceData['platform'] = 'macOS';
|
||||
deviceData['model'] = macInfo.model;
|
||||
deviceData['version'] = macInfo.systemGUID;
|
||||
} else if (Platform.isWindows) {
|
||||
WindowsDeviceInfo windowsInfo = await deviceInfoPlugin.windowsInfo;
|
||||
deviceData['platform'] = 'Windows';
|
||||
deviceData['manufacturer'] = windowsInfo.computerName;
|
||||
deviceData['version'] = windowsInfo.majorVersion;
|
||||
deviceData['deviceId'] = windowsInfo.deviceId;
|
||||
deviceData['userName'] = windowsInfo.userName;
|
||||
deviceData['productName'] = windowsInfo.productName;
|
||||
deviceData['installDate'] = windowsInfo.installDate;
|
||||
deviceData['productId'] = windowsInfo.productId;
|
||||
deviceData['numberOfCores'] = windowsInfo.numberOfCores;
|
||||
deviceData['systemMemoryInMegabytes'] =
|
||||
windowsInfo.systemMemoryInMegabytes;
|
||||
} else if (Platform.isLinux) {
|
||||
LinuxDeviceInfo linuxInfo = await deviceInfoPlugin.linuxInfo;
|
||||
deviceData['platform'] = 'Linux';
|
||||
deviceData['manufacturer'] = linuxInfo.name;
|
||||
deviceData['version'] = linuxInfo.version;
|
||||
}
|
||||
} catch (e) {
|
||||
print('Failed to get device info: $e');
|
||||
}
|
||||
|
||||
return deviceData;
|
||||
}
|
||||
}
|
||||
41
lib/controller/functions/document_scanner.dart
Normal file
41
lib/controller/functions/document_scanner.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:google_ml_kit/google_ml_kit.dart';
|
||||
|
||||
class ImagePickerController extends GetxController {
|
||||
RxBool textScanning = false.obs;
|
||||
RxString scannedText = ''.obs;
|
||||
|
||||
Future<void> getImage(ImageSource source) async {
|
||||
try {
|
||||
final pickedImage = await ImagePicker().pickImage(source: source);
|
||||
if (pickedImage != null) {
|
||||
textScanning.value = true;
|
||||
final imageFile = File(pickedImage.path);
|
||||
getRecognisedText(imageFile);
|
||||
}
|
||||
} catch (e) {
|
||||
textScanning.value = false;
|
||||
scannedText.value = "Error occurred while scanning";
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getRecognisedText(File image) async {
|
||||
final inputImage = InputImage.fromFilePath(image.path);
|
||||
final textDetector = GoogleMlKit.vision.textRecognizer();
|
||||
final RecognizedText recognisedText =
|
||||
await textDetector.processImage(inputImage);
|
||||
await textDetector.close();
|
||||
|
||||
scannedText.value = '';
|
||||
for (TextBlock block in recognisedText.blocks) {
|
||||
for (TextLine line in block.lines) {
|
||||
scannedText.value += line.text + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
textScanning.value = false;
|
||||
}
|
||||
}
|
||||
23
lib/controller/functions/twilio_service.dart
Normal file
23
lib/controller/functions/twilio_service.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:ride/constant/credential.dart';
|
||||
import 'package:twilio_flutter/twilio_flutter.dart';
|
||||
|
||||
class TwilioSMS {
|
||||
TwilioFlutter twilioFlutter = TwilioFlutter(
|
||||
accountSid: AppCredintials.accountSIDTwillo,
|
||||
authToken: AppCredintials.authTokenTwillo,
|
||||
twilioNumber: '+962 7 9858 3052');
|
||||
|
||||
Future<void> sendSMS({
|
||||
required String recipientPhoneNumber,
|
||||
required String message,
|
||||
}) async {
|
||||
try {
|
||||
await twilioFlutter.sendSMS(
|
||||
toNumber: recipientPhoneNumber,
|
||||
messageBody: message,
|
||||
);
|
||||
} catch (e) {
|
||||
print(e); // Print the exception to the console.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,16 @@ import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/controller/functions/twilio_service.dart';
|
||||
import 'package:ride/controller/home/captin/home_captain_controller.dart';
|
||||
import 'package:ride/controller/home/captin/order_request_controller.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/Rate/ride_calculate_driver.dart';
|
||||
import 'package:ride/views/home/Captin/text_scanner.dart';
|
||||
import 'package:ride/views/widgets/circle_container.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
||||
import 'package:twilio_flutter/twilio_flutter.dart';
|
||||
|
||||
import '../../../controller/functions/location_controller.dart';
|
||||
import '../../../controller/home/captin/widget/connect.dart';
|
||||
@@ -137,7 +140,7 @@ class HomeCaptain extends StatelessWidget {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.to(() => RideCalculateDriver());
|
||||
Get.to(() => const RideCalculateDriver());
|
||||
},
|
||||
child: const Text('Chart')),
|
||||
const Wrap(
|
||||
@@ -169,6 +172,22 @@ class HomeCaptain extends StatelessWidget {
|
||||
Icon(Zocial.github),
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
TwilioSMS().sendSMS(
|
||||
recipientPhoneNumber: '+962 7 9858 3052',
|
||||
message: 'Hello, this is a test message.',
|
||||
);
|
||||
},
|
||||
child: const Icon(MaterialIcons.message)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.to(() => TextScanner());
|
||||
},
|
||||
child: const Text(
|
||||
"Text Scanner",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
47
lib/views/home/Captin/text_scanner.dart
Normal file
47
lib/views/home/Captin/text_scanner.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
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.gallery),
|
||||
child: const Text('Take Picture'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user