10/20/1
This commit is contained in:
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user