master
aamir-csol 3 days ago
parent 5ad012d602
commit 9f4e9943cf

@ -4,12 +4,12 @@ class ApiConsts {
// static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "http://10.200.204.11"; // Local server
// static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA 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 = "http://10.201.204.101:2024";
// static String baseUrl = "https://webservices.hmg.com"; // PreProd // static String baseUrl = "https://webservices.hmg.com"; // PreProd
// static String baseUrl = "https://hmgwebservices.com"; // Live server // 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/"; // static String baseUrl = "http://10.20.200.111:1010/";

@ -194,8 +194,35 @@ class _MowadhafhiHRRequestState extends State<MowadhafhiHRRequest> {
SimpleButton(LocaleKeys.add.tr(), () async { SimpleButton(LocaleKeys.add.tr(), () async {
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true); FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true);
if (result != null) { if (result != null) {
attachmentFiles = attachmentFiles + result.paths.map((path) => File(path!)).toList(); // Maximum file size: 2 MB (in bytes)
attachmentFiles = attachmentFiles.toSet().toList(); const int maxFileSizeInBytes = 2 * 1024 * 1024; // 2 MB
List<File> newFiles = [];
List<String> 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(() {}); setState(() {});
} }
}, fontSize: 14), }, fontSize: 14),

Loading…
Cancel
Save