diff --git a/lib/ui/misc/request_submit_screen.dart b/lib/ui/misc/request_submit_screen.dart index d1264fd..3611241 100644 --- a/lib/ui/misc/request_submit_screen.dart +++ b/lib/ui/misc/request_submit_screen.dart @@ -1,3 +1,4 @@ +import 'dart:convert'; import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; @@ -71,27 +72,31 @@ class _RequestSubmitScreenState extends State { } } + Future>> addAttachments() async { + List> list = []; + if (attachmentFiles.isNotEmpty) { + attachmentFiles.asMap().forEach((index, value) { + String type = attachmentFiles[index].path.split('.').last; + String name = attachmentFiles[index].path.split('/').last; + List fileContent = value.readAsBytesSync(); + String encodedFile = base64Encode(fileContent); + list.add(AttachmentModel( + attachmentID: index, + pFILECONTENTTYPE: type, + pFILENAME: name, + pFILEDATA: encodedFile, + pTRANSACTIONID: params!.transactionId, + ).toJson()); + }); + } + return list; + } + void submitRequest() async { try { Utils.showLoading(context); - List> list = []; - if (attachmentFiles.isNotEmpty) { - attachments.asMap().forEach((index, value) async { - String type = attachmentFiles[index].path.split('.').last; - String name = attachmentFiles[index].path.split('/').last; - // List fileContent = await value.readAsBytes(); - // String encodedFile = base64Encode(fileContent); - list.add(AttachmentModel( - attachmentID: index, - pFILECONTENTTYPE: type, - pFILENAME: name, - pFILEDATA: value, - pTRANSACTIONID: params!.transactionId, - ).toJson()); - }); - } + List> list = await addAttachments(); await MyAttendanceApiClient().addAttachment(list); - if (params!.approvalFlag == 'phone_numbers') { await ProfileApiClient().startPhoneApprovalProcess( "SUBMIT",