This commit is contained in:
Surendiran 2026-01-23 19:08:28 +05:30
commit d991ee2a49
4 changed files with 93 additions and 47 deletions

File diff suppressed because one or more lines are too long

View File

@ -392,6 +392,10 @@ class BrokerState extends ConsumerState<Broker> {
child: ThemedFormInlineField( child: ThemedFormInlineField(
controller: controllers['code']!, controller: controllers['code']!,
validator: (value) => Validators.requiredField(value, "code"), validator: (value) => Validators.requiredField(value, "code"),
inputFormatters: [
// This line now allows letters, numbers, hyphens, and underscores
FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9\-_ ]')),
],
txtwidth: MediaQuery.of(context).size.width * 0.15, txtwidth: MediaQuery.of(context).size.width * 0.15,
borderColor: Color(0xFFE2E8F0), borderColor: Color(0xFFE2E8F0),
highlightColor: Color(0xFF50A398), highlightColor: Color(0xFF50A398),

View File

@ -94,7 +94,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
'enquiry_vehicle_type_id_for_commission', 'enquiry_vehicle_type_id_for_commission',
//find Policy //find Policy
'insurance_plan_type', 'insurance_plan_type_id',
]; ];
late Map<String, TextEditingController> controllers; late Map<String, TextEditingController> controllers;
String? selectedInsuranceId; String? selectedInsuranceId;
@ -129,6 +129,8 @@ class _policyValidationState extends ConsumerState<policyValidation> {
String? selectedPaymentMode; String? selectedPaymentMode;
String? selectedFuelType; String? selectedFuelType;
String? selectedBroker; String? selectedBroker;
String? selectedInsurerName;
String? selectedInsurerShortName;
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKey = final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKey =
GlobalKey<DropdownSearchState<Map<String, dynamic>>>(); GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
@ -282,7 +284,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
? controllers["payment_mode"]?.text ? controllers["payment_mode"]?.text
: selectedPaymentMode, : selectedPaymentMode,
"insurance_plan_type_id": selectedInsurancePlanTypeId, "insurance_plan_type_id": selectedInsurancePlanTypeId,
// "insurance_plan_type": controllers["insurance_plan_type"]?.text.trim().isNotEmpty == true ? controllers['insurance_plan_type']?.text : selectedInsurancPlanType,
}; };
} }
@ -707,6 +708,8 @@ class _policyValidationState extends ConsumerState<policyValidation> {
if (!mounted) return; if (!mounted) return;
debugPrint('findPolicyApi response2:'); debugPrint('findPolicyApi response2:');
setState(() { setState(() {
selectedInsurerShortName = safeText(data['insurer_short_name']);
selectedInsurerName = safeText(data['insurer_name']);
controllers["policyNumber"]?.text = safeText(data['policy_number']); controllers["policyNumber"]?.text = safeText(data['policy_number']);
controllers["insuredName"]!.text = safeText(data['insured_name']); controllers["insuredName"]!.text = safeText(data['insured_name']);
controllers["premiumAmount"]!.text = safeText(data['premium_amount']); controllers["premiumAmount"]!.text = safeText(data['premium_amount']);
@ -753,23 +756,6 @@ class _policyValidationState extends ConsumerState<policyValidation> {
data['year_of_manufacture'], data['year_of_manufacture'],
); );
// selectedInsurancPlanType = safeText(data['insurance_plan_type']);
// controllers["insurance_plan_type"]?.text = safeText(data['insurance_plan_type']);
final planName = safeText(data['insurance_plan_type']);
final matchedPlan = filteredInsurancPlanTypeData.firstWhere(
(item) =>
item['insurance_plan_type']
.toString()
.toLowerCase() ==
planName.toLowerCase(),
orElse: () => {},
);
if (matchedPlan.isNotEmpty) {
selectedInsurancePlanTypeId = matchedPlan['id'].toString();
}
selectedInsuranceId = safeText(data['insurer_id']); selectedInsuranceId = safeText(data['insurer_id']);
selectedAgentRentionRate = safeText(data['agent_retention_rate']); selectedAgentRentionRate = safeText(data['agent_retention_rate']);
selectedManagerRentionRate = safeText(data['manager_retention_rate']); selectedManagerRentionRate = safeText(data['manager_retention_rate']);
@ -782,6 +768,11 @@ class _policyValidationState extends ConsumerState<policyValidation> {
selectedVehicleTypeForEnquiryID = data['enquiry_vehicle_type_id_for_commission']?.toString() ?? ''; selectedVehicleTypeForEnquiryID = data['enquiry_vehicle_type_id_for_commission']?.toString() ?? '';
controllers["enquiry_reg_no_for_commission"]?.text = safeText(data['enquiry_reg_no_for_commission']); controllers["enquiry_reg_no_for_commission"]?.text = safeText(data['enquiry_reg_no_for_commission']);
// controllers["rcNo"]!.text = safeText(data['rc_no']); // controllers["rcNo"]!.text = safeText(data['rc_no']);
// 1. Set the State variable (This makes the Dropdown show the correct item)
selectedInsurancePlanTypeId = data['insurance_plan_type_id']?.toString();
// 2. Set the Controller (This ensures dataDetails() can pick it up if needed)
controllers["insurance_plan_type_id"]?.text = selectedInsurancePlanTypeId ?? '';
}); });
debugPrint('findPolicyApi response3:'); debugPrint('findPolicyApi response3:');
@ -1466,7 +1457,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
} }
Widget buildInsurancPlanType(BuildContext context) { Widget buildInsurancPlanType(BuildContext context) {
final Map<String, dynamic>? selectedPlan = final Map<String, dynamic>? selectedIPT =
selectedInsurancePlanTypeId != null selectedInsurancePlanTypeId != null
? filteredInsurancPlanTypeData.firstWhere( ? filteredInsurancPlanTypeData.firstWhere(
(item) => (item) =>
@ -1487,28 +1478,46 @@ class _policyValidationState extends ConsumerState<policyValidation> {
), ),
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
DropdownSearch<Map<String, dynamic>>( DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyInsurancPlanType, key: dropDownKeyInsurancPlanType,
items: (filter, _) => filteredInsurancPlanTypeData, items: (filter, _) => filteredInsurancPlanTypeData,
// disabledItemFn: (item) => item['is_active'] == "0",
selectedItem:
selectedPlan != null && selectedPlan.isNotEmpty
? selectedPlan
: null,
itemAsString: (item) =>
item['insurance_plan_type'].toString(),
compareFn: (a, b) => compareFn: (a, b) =>
a['id'].toString() == b['id'].toString(), a['id'].toString() == b['id'].toString(),
selectedItem: selectedIPT != null && selectedIPT.isNotEmpty
? selectedIPT
: null,
itemAsString: (item) => item['insurance_plan_type'].toString(),
// 2. Styling for the items in the list
popupProps: PopupProps.menu(
itemBuilder: (context, item, isSelected, isHovered) {
final bool isActive = item['is_active'] == "1";
return ListTile(
title: Text(
item['insurance_plan_type'].toString(),
style: TextStyle(
// Gray out text if inactive
color: isActive ? Colors.black : Colors.grey,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
// Add a "Disabled" subtitle for clarity
subtitle: isActive ? null : const Text("Inactive", style: TextStyle(fontSize: 10, color: Colors.red)),
);
},
),
onChanged: (val) { onChanged: (val) {
if (val != null) { if (val != null) {
// setState(() { selectedInsurancePlanTypeId = val['id'].toString(); // store ID
selectedInsurancePlanTypeId = // WRITE INTO CONTROLLER (CRITICAL)
val['id'].toString(); controllers['insurance_plan_type_id']?.text = selectedInsurancePlanTypeId!;
// });
} }
}, },
@ -1522,7 +1531,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
} }
Widget _sectionHeader(String title, {IconData icon = Icons.info}) { Widget _sectionHeader(String title, {IconData icon = Icons.info , String? rightTitle,}) {
return Container( return Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12), padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -1544,6 +1553,18 @@ class _policyValidationState extends ConsumerState<policyValidation> {
title, title,
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600), style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600),
), ),
// Push right title to end
const Spacer(),
// Right title (optional)
if (rightTitle != null && rightTitle.isNotEmpty)
Text(
rightTitle,
style: GoogleFonts.poppins(
fontWeight: FontWeight.w600,
fontSize: 12,
),
),
], ],
), ),
); );
@ -1559,13 +1580,32 @@ class _policyValidationState extends ConsumerState<policyValidation> {
String? hintText, String? hintText,
List<TextInputFormatter>? inputFormatters, // 👈 ADD THIS List<TextInputFormatter>? inputFormatters, // 👈 ADD THIS
ValueChanged<String>? onChanged, // 👈 ADD THIS ValueChanged<String>? onChanged, // 👈 ADD THIS
String? rightLabel, // 👈 ADD THIS
}) { }) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( // Text(
label, // label,
style: GoogleFonts.poppins(fontWeight: FontWeight.w500, fontSize: 11), // style: GoogleFonts.poppins(fontWeight: FontWeight.w500, fontSize: 11),
// ),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: GoogleFonts.poppins(fontWeight: FontWeight.w500, fontSize: 11),
),
if (rightLabel != null)
Text(
rightLabel,
style: GoogleFonts.poppins(
fontWeight: FontWeight.w500,
fontSize: 11,
color: Colors.grey[700],
),
),
],
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
TextFormField( TextFormField(
@ -1822,6 +1862,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
_sectionHeader( _sectionHeader(
'Policy Details', 'Policy Details',
icon: Icons.policy, icon: Icons.policy,
rightTitle: selectedInsurerShortName?.isNotEmpty == true ? 'INSURER - ${selectedInsurerShortName}' : '',
), ),
SizedBox(height: 10), SizedBox(height: 10),
Row( Row(
@ -1831,6 +1872,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
'Policy Number *', 'Policy Number *',
controllers['policyNumber']!, controllers['policyNumber']!,
required: true, required: true,
// rightLabel: selectedInsurerName,
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),

View File

@ -700,26 +700,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "11.0.2" version: "10.0.9"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.10" version: "3.0.9"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -1297,10 +1297,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.6" version: "0.7.4"
toastification: toastification:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1417,10 +1417,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.0" version: "2.1.4"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description: