This commit is contained in:
venba-Inspriron-3558 2025-06-12 19:04:06 +05:30
parent b81f3803e0
commit 400a7a2ec0
2 changed files with 67 additions and 1 deletions

View File

@ -311,7 +311,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Number of Passenger",
"Number of Passenger *",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w500,

View File

@ -897,6 +897,72 @@ class ApiService {
}
}
// download the Template for bulk upload the user
Future<void> getDownloadUserTemplateForUpload() async {
final String apiUrldata = '$apiUrl/api/user/userUploadTemplate'; // download the Template for bulk upload user => api
// final String apiUrldata = '$apiUrl/auth/googlelogin';
final token = await getToken();
if (token == null) {
throw Exception('Token not found. Please log in.');
}
final response = await http.get(
Uri.parse(apiUrldata),
headers: {
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
},
);
if (response.statusCode == 200) {
try {
print("XL Dowloaded");
// Create a blob from the response body
final blob = html.Blob([response.bodyBytes]);
// Generate a download URL for the blob
final url = html.Url.createObjectUrlFromBlob(blob);
// Create a link element to trigger the download
final anchor =
html.AnchorElement(href: url)
..setAttribute('download', 'user_file.xlsx')
..click();
// Revoke the download URL to free up resources
html.Url.revokeObjectUrl(url);
} catch (e) {
throw Exception('Error parsing response: $e');
}
} else if (response.statusCode == 404) {
// showDialog(
// context: context,
// builder: (BuildContext context) {
// return AlertDialog(
// title: Text('File not found.'),
// // content: Text('File not found.'),
// actions: [
// TextButton(
// child: Text('OK'),
// onPressed: () {
// Navigator.of(context).pop(); // Close the dialog
// },
// ),
// ],
// );
// },
// );
} else {
throw Exception('Failed to load plans');
}
}
//---------------------------------------User Management-----------------------------------
Future<Map<String, dynamic>> getSingleUser(int userId) async {