Fromatting and localizations

This commit is contained in:
2025-12-31 12:44:39 +05:30
parent 60270a5fa9
commit 54a7b8f1b0
21 changed files with 501 additions and 194 deletions

View File

@@ -1,6 +1,7 @@
import 'dart:convert';
import 'package:dio/dio.dart';
class Cheque {
final String? type;
final String? InstrType;
@@ -17,19 +18,19 @@ class Cheque {
final String? StopExpiryDate;
Cheque({
this.type,
this.InstrType,
this.Date,
this.branchCode,
this.fromCheque,
this.toCheque,
this.Chequescount,
this.ChequeNumber,
this.transactionCode,
this.amount,
this.status,
this.stopIssueDate,
this.StopExpiryDate,
this.type,
this.InstrType,
this.Date,
this.branchCode,
this.fromCheque,
this.toCheque,
this.Chequescount,
this.ChequeNumber,
this.transactionCode,
this.amount,
this.status,
this.stopIssueDate,
this.StopExpiryDate,
});
factory Cheque.fromJson(Map<String, dynamic> json) {
@@ -47,7 +48,7 @@ this.StopExpiryDate,
status: json['status'] ?? '',
stopIssueDate: json['stopIssueDate'] ?? '',
StopExpiryDate: json['StopExpiryDate'] ?? '',
);
);
}
static List<Cheque> listFromJson(List<dynamic> jsonList) {
@@ -61,17 +62,17 @@ class ChequeService {
final Dio _dio;
ChequeService(this._dio);
Future<List<Cheque>> ChequeEnquiry(
{required String accountNumber,
Future<List<Cheque>> ChequeEnquiry({
required String accountNumber,
required String instrType,
}) async {
}) async {
try {
final response = await _dio.get(
"/api/cheque/enquiry",
queryParameters: {
'accountNumber': accountNumber,
'instrumentType': instrType,
},
'accountNumber': accountNumber,
'instrumentType': instrType,
},
options: Options(
headers: {
"Content-Type": "application/json",
@@ -80,13 +81,15 @@ class ChequeService {
);
if (response.statusCode == 200) {
if (response.data is Map<String, dynamic> && response.data.containsKey('records')) {
if (response.data is Map<String, dynamic> &&
response.data.containsKey('records')) {
final records = response.data['records'];
if (records is List) {
return Cheque.listFromJson(records);
}
}
throw Exception("Unexpected API response format: 'records' list not found or malformed");
throw Exception(
"Unexpected API response format: 'records' list not found or malformed");
} else {
throw Exception("Failed to fetch");
}
@@ -101,21 +104,19 @@ class ChequeService {
required String stopFromChequeNo,
required String instrType,
String? stopToChequeNo,
String? stopIssueDate,
String? stopExpiryDate,
String? stopAmount,
String? stopComment,
String? chequeIssueDate,
required String tpin,
String? stopIssueDate,
String? stopExpiryDate,
String? stopAmount,
String? stopComment,
String? chequeIssueDate,
required String tpin,
}) async {
final response = await _dio.post(
final response = await _dio.post(
'/api/cheque/stop',
options: Options(
validateStatus: (int? status) => true,
receiveDataWhenStatusError: true,
),
options: Options(
validateStatus: (int? status) => true,
receiveDataWhenStatusError: true,
),
data: {
'accountNumber': accountno,
'stopFromChequeNo': stopFromChequeNo,
@@ -126,12 +127,12 @@ class ChequeService {
'stopAmount': stopAmount,
'stopComment': stopComment,
'chqIssueDate': chequeIssueDate,
'tpin':tpin,
'tpin': tpin,
},
);
if (response.statusCode != 200) {
throw Exception(jsonEncode(response.data));
}
return response.toString();
if (response.statusCode != 200) {
throw Exception(jsonEncode(response.data));
}
return response.toString();
}
}