12/3/1
This commit is contained in:
@@ -10,13 +10,13 @@ import 'package:ride/constant/api_key.dart';
|
||||
import 'package:ride/constant/box_name.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/info.dart';
|
||||
import 'package:ride/constant/links.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/constant/table_names.dart';
|
||||
import 'package:ride/main.dart';
|
||||
import 'package:ride/views/widgets/elevated_btn.dart';
|
||||
|
||||
import '../../views/auth/captin/car_license_page.dart';
|
||||
import '../../constant/links.dart';
|
||||
import '../auth/captin/register_captin_controller.dart';
|
||||
import 'launch.dart';
|
||||
|
||||
//
|
||||
@@ -227,6 +227,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
late Uint8List imageSignature;
|
||||
late Uint8List imageDocumentFrontSide;
|
||||
XFile? image;
|
||||
XFile? imagePortraitFile;
|
||||
XFile? imageFace;
|
||||
late File tempFile;
|
||||
late String imagePath;
|
||||
@@ -327,6 +328,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
await tempFile.writeAsBytes(imagePortrait);
|
||||
|
||||
imagePath = tempFile.path;
|
||||
// imagePortraitFile=File(imagePath) ;
|
||||
update();
|
||||
} else {
|
||||
// Handle error or provide a default value
|
||||
@@ -446,7 +448,7 @@ class ScanDocumentsByApi extends GetxController {
|
||||
},
|
||||
)) //
|
||||
: Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
// barrierDismissible: false,
|
||||
title: 'Image detecting result is '.tr,
|
||||
titleStyle: AppStyle.title,
|
||||
content: Column(
|
||||
@@ -478,47 +480,59 @@ class ScanDocumentsByApi extends GetxController {
|
||||
: MyElevatedButton(
|
||||
title: 'Next'.tr,
|
||||
onPressed: () async {
|
||||
await uploadImage(
|
||||
tempFile, AppLink.uploadImagePortrate);
|
||||
Get.to(() => CarLicensePage());
|
||||
RegisterCaptainController registerCaptainController =
|
||||
Get.put(RegisterCaptainController());
|
||||
|
||||
await registerCaptainController.register();
|
||||
await registerCaptainController.addLisence();
|
||||
await uploadImagePortrate();
|
||||
// Get.to(() => CarLicensePage());
|
||||
},
|
||||
// {
|
||||
// await uploadImage(
|
||||
// tempFile, AppLink.uploadImagePortrate);
|
||||
// Get.to(() => CarLicensePage());
|
||||
// },
|
||||
kolor: AppColor.greenColor,
|
||||
));
|
||||
} else {
|
||||
print(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
// Todo upload images and fields
|
||||
|
||||
Future<String> uploadImage(File imageFile, String link) async {
|
||||
String? basicAuthCredentials =
|
||||
await storage.read(key: BoxName.basicAuthCredentials);
|
||||
// Todo upload images and fields
|
||||
Future<String> uploadImagePortrate() async {
|
||||
isLoading = true;
|
||||
update();
|
||||
|
||||
var request = http.MultipartRequest(
|
||||
'POST',
|
||||
Uri.parse(link), //AppLink.uploadImage
|
||||
Uri.parse(AppLink.uploadImagePortrate),
|
||||
);
|
||||
|
||||
// Attach the image file to the request
|
||||
request.files.add(
|
||||
await http.MultipartFile.fromPath('image', imageFile.path),
|
||||
); // Add the headers to the request
|
||||
request.headers.addAll({
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(basicAuthCredentials.toString()))}',
|
||||
});
|
||||
http.MultipartFile.fromBytes('image', imagePortrait),
|
||||
);
|
||||
|
||||
request.headers.addAll({
|
||||
"Content-Type": "multipart/form-data",
|
||||
'Authorization':
|
||||
'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
|
||||
});
|
||||
request.fields['driverID'] =
|
||||
'bnbn'; // box.read(BoxName.driverID).toString();
|
||||
|
||||
// Add the driverID to the request
|
||||
request.fields['driverID'] = box.read(BoxName.driverID);
|
||||
// Send the request
|
||||
var response = await request.send();
|
||||
|
||||
// Read the response
|
||||
var responseData = await response.stream.toBytes();
|
||||
var responseString = String.fromCharCodes(responseData);
|
||||
// scannedText = responseString;
|
||||
|
||||
isLoading = false;
|
||||
update();
|
||||
// Return the link received from the server
|
||||
|
||||
// Print the response string
|
||||
print(responseString);
|
||||
|
||||
return responseString;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user