diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 88ebf73..d8efe5d 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -4,12 +4,12 @@ class ApiConsts { // static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "http://10.201.204.101:2024"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://hmgwebservices.com"; // Live server - static String baseUrl = "https://mohemm.hmg.com"; // New Live server + // static String baseUrl = "https://mohemm.hmg.com"; // New Live server // // static String baseUrl = "http://10.20.200.111:1010/"; diff --git a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart index e7d2fde..ec12c51 100644 --- a/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart +++ b/lib/ui/screens/mowadhafhi/mowadhafhi_hr_request.dart @@ -194,8 +194,35 @@ class _MowadhafhiHRRequestState extends State { SimpleButton(LocaleKeys.add.tr(), () async { FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); if (result != null) { - attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList(); - attachmentFiles = attachmentFiles.toSet().toList(); + // Maximum file size: 2 MB (in bytes) + const int maxFileSizeInBytes = 2 * 1024 * 1024; // 2 MB + List newFiles = []; + List oversizedFiles = []; + + for (String? path in result.paths) { + if (path != null) { + File file = File(path); + int fileSize = await file.length(); + + if (fileSize <= maxFileSizeInBytes) { + newFiles.add(file); + } else { + String fileName = path.split('/').last; + oversizedFiles.add(fileName); + } + } + } + + if (newFiles.isNotEmpty) { + attachmentFiles = attachmentFiles + newFiles; + attachmentFiles = attachmentFiles.toSet().toList(); + } + + if (oversizedFiles.isNotEmpty) { + // String fileList = oversizedFiles.join(', '); + Utils.showToast('File exceeds 2 MB limit'); + } + setState(() {}); } }, fontSize: 14),