dropdown fixes

This commit is contained in:
venba-Inspriron-3558 2025-06-10 10:41:40 +05:30
parent 4887c69950
commit 424d93cc9f
7 changed files with 1012 additions and 319 deletions

View File

@ -1145,6 +1145,51 @@ class _ForexScreenState extends State<ForexScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
// CustomTextFieldForexWrapper(
// isFocused: focusStates["_countries"] ?? false,
// isDesktop: isDesktop,
// child: SizedBox(
// height: 40,
// child: DropdownSearch<String>(
// selectedItem: countryMap[selectedCountry],
// popupProps: PopupProps.menu(
// showSearchBox: true, // Enables search functionality
// searchFieldProps: TextFieldProps(
// decoration: InputDecoration(
// hintText: "Search ...",
// contentPadding: EdgeInsets.symmetric(horizontal: 10),
// ),
// ),
// ),
// items: countryMap.values.toList(),
// dropdownDecoratorProps: DropDownDecoratorProps(
// dropdownSearchDecoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(horizontal: 1),
// ),
// ),
// dropdownBuilder:
// (context, selectedItem) => Align(
// // Center-align selected item
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem ?? "Select ",
// style: TextStyle(fontSize: 12),
// ),
// ),
// onChanged: (String? newValue) {
// setState(() {
// // Find the country_code based on selected country_name
// selectedCountry =
// countryMap.entries
// .firstWhere((entry) => entry.value == newValue)
// .key;
// _onCountryChanged(selectedCountry);
// });
// },
// ),
// ),
// ),
CustomTextFieldForexWrapper( CustomTextFieldForexWrapper(
isFocused: focusStates["_countries"] ?? false, isFocused: focusStates["_countries"] ?? false,
isDesktop: isDesktop, isDesktop: isDesktop,
@ -1153,7 +1198,22 @@ class _ForexScreenState extends State<ForexScreen> {
child: DropdownSearch<String>( child: DropdownSearch<String>(
selectedItem: countryMap[selectedCountry], selectedItem: countryMap[selectedCountry],
popupProps: PopupProps.menu( popupProps: PopupProps.menu(
showSearchBox: true, // Enables search functionality showSearchBox: true,
fit: FlexFit.loose,
constraints: BoxConstraints(maxHeight: 250),
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder:
(context, item, isSelected) => Container(
color: Colors.white,
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 6,
),
child: Text(
item,
style: GoogleFonts.poppins(fontSize: 11.5),
),
),
searchFieldProps: TextFieldProps( searchFieldProps: TextFieldProps(
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Search ...", hintText: "Search ...",
@ -1170,13 +1230,15 @@ class _ForexScreenState extends State<ForexScreen> {
), ),
dropdownBuilder: dropdownBuilder:
(context, selectedItem) => Align( (context, selectedItem) => Align(
// Center-align selected item alignment: Alignment.centerLeft,
alignment: Alignment.centerLeft, child: Text(
child: Text( selectedItem ?? "Select ",
selectedItem ?? "Select ", style: GoogleFonts.poppins(
style: TextStyle(fontSize: 12), fontSize: 12,
), color: Colors.black,
), ),
),
),
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
// Find the country_code based on selected country_name // Find the country_code based on selected country_name

View File

@ -695,56 +695,128 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
), ),
const SizedBox(height: 5), const SizedBox(height: 5),
// Dropdown Wrapper
// CustomTextFieldWrapper(
// isFocused: _isHotelNameFocused,
// isDesktop: isDesktop,
// width: isDesktop ? MediaQuery.of(context).size.width * 0.31 : null,
// child: SizedBox(
// height: 35,
// width: double.infinity,
// child: DropdownButtonFormField<String>(
// focusNode: _tripTypeFocusNode,
// value: selectedInsuranceType,
// style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
// decoration: const InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 5,
// ),
// ),
// hint: Text(
// "Select ",
// style: GoogleFonts.poppins(color: Colors.grey, fontSize: 13),
// ),
// items:
// purposeList.map<DropdownMenuItem<String>>((item) {
// return DropdownMenuItem<String>(
// value: item['dropdown_key'],
// child: Text(
// item['dropdown_value'] ?? '',
// style: GoogleFonts.poppins(fontSize: 12),
// ),
// );
// }).toList(),
// onChanged:
// purposeList.isNotEmpty
// ? (String? newValue) {
// setState(() {
// selectedInsuranceType = newValue;
// if ((selectedInsuranceType ?? '').isNotEmpty) {
// errorMessages.remove("type_of_insurance");
// }
// });
// print(
// "Selected Insurance Type: $selectedInsuranceType",
// );
// }
// : null,
// ),
// ),
// ),
// Dropdown Wrapper // Dropdown Wrapper
CustomTextFieldWrapper( CustomTextFieldWrapper(
isFocused: _isHotelNameFocused, isFocused: _isHotelNameFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
width: isDesktop ? MediaQuery.of(context).size.width * 0.31 : null, width: isDesktop ? MediaQuery.of(context).size.width * 0.31 : null,
child: SizedBox( child: SizedBox(
height: 35, height: 40,
width: double.infinity, width: double.infinity,
child: DropdownButtonFormField<String>( child: DropdownSearch<Map<String, dynamic>>(
focusNode: _tripTypeFocusNode, items: purposeList.cast<Map<String, dynamic>>(),
value: selectedInsuranceType, selectedItem: purposeList.firstWhere(
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), (item) => item['dropdown_key'] == selectedInsuranceType,
decoration: const InputDecoration( orElse: () => {},
border: InputBorder.none, ),
contentPadding: EdgeInsets.symmetric( itemAsString: (item) => item['dropdown_value'] ?? '',
horizontal: 10, popupProps: PopupProps.menu(
vertical: 5, showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,),
), ),
), ),
hint: Text( dropdownBuilder: (context, selectedItem) {
"Select ", if (selectedItem == null || selectedItem.isEmpty) {
style: GoogleFonts.poppins(color: Colors.grey, fontSize: 13), return Text(
), "Select ",
items: style: GoogleFonts.poppins(
purposeList.map<DropdownMenuItem<String>>((item) { color: Colors.grey,
return DropdownMenuItem<String>( fontSize: 13,
value: item['dropdown_key'], ),
child: Text( );
item['dropdown_value'] ?? '', }
style: GoogleFonts.poppins(fontSize: 12), return Text(
), selectedItem['dropdown_value'] ?? '',
); style: GoogleFonts.poppins(
}).toList(), fontSize: 12,
color: Colors.black,
),
);
},
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (String? newValue) { ? (Map<String, dynamic>? newValue) {
setState(() { setState(() {
selectedInsuranceType = newValue; selectedInsuranceType= newValue?['dropdown_key'];
if ((selectedInsuranceType ?? '').isNotEmpty) { print("selected Insurance Type: ${selectedInsuranceType}");
errorMessages.remove("type_of_insurance"); });
} }
}); : null,
print(
"Selected Insurance Type: $selectedInsuranceType",
);
}
: null,
), ),
), ),
), ),
], ],
), ),

View File

@ -1,3 +1,4 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -244,36 +245,114 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
dropdownItems.isNotEmpty ? dropdownItems.first.value : "No options"; dropdownItems.isNotEmpty ? dropdownItems.first.value : "No options";
return [ return [
CustomTextFieldWrapper( // CustomTextFieldWrapper(
// isFocused: _isHotelNameFocused,
// isDesktop: isDesktop,
// width:
// isDesktop
// ? MediaQuery.of(context).size.width * 0.34
// : MediaQuery.of(context).size.width * 0.66,
// child: SizedBox(
// height: 40,
// child: DropdownButtonFormField<String>(
// focusNode: _tripTypeFocusNode, // Assign the correct focus node
// value: selectedSpecialType,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ), // Proper padding
// ),
// onChanged:
// purposeList.isNotEmpty
// ? (newValue) {
// setState(() {
// selectedSpecialType = newValue;
// });
//
// print(selectedSpecialType);
// }
// : null,
// items: dropdownItems,
// ),
// ),
// ),
CustomTextFieldItnerarySubWrapper(
isFocused: _isHotelNameFocused, isFocused: _isHotelNameFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
width: width: isDesktop
isDesktop ? MediaQuery.of(context).size.width * 0.34
? MediaQuery.of(context).size.width * 0.34 : MediaQuery.of(context).size.width * 0.66,
: MediaQuery.of(context).size.width * 0.66,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( width: double.infinity,
focusNode: _tripTypeFocusNode, // Assign the correct focus node child: DropdownSearch<Map<String, dynamic>>(
value: selectedSpecialType, // focusNode: _taxiReqFocusNode,
style: TextStyle(fontSize: 12), items: purposeList.cast<Map<String, dynamic>>(),
decoration: InputDecoration( selectedItem: purposeList.firstWhere(
border: InputBorder.none, (item) => item['dropdown_key'] == selectedSpecialType,
contentPadding: EdgeInsets.symmetric( orElse: () => {},
horizontal: 10,
), // Proper padding
), ),
itemAsString: (item) => item['dropdown_value'] ?? '',
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select ",
style: GoogleFonts.poppins(
color: Colors.grey,
fontSize: 13,
),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
);
},
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (newValue) { ? (newValue) {
setState(() { setState(() {
selectedSpecialType = newValue; selectedSpecialType = newValue as String?;
}); });
print(
print(selectedSpecialType); "Updating form data: -> ${newValue ?? ""}",
} );
: null, }
items: dropdownItems, : null,
), ),
), ),
), ),

View File

@ -1,3 +1,4 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
@ -362,34 +363,109 @@ class _TaxiScreenState extends State<TaxiScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
// CustomTextFieldItnerarySubWrapper(
// isFocused: _toFocus,
// isDesktop: isDesktop,
// child: SizedBox(
// height: 40,
// child: DropdownButtonFormField<String>(
// focusNode: _toFocusNode, // Assign the correct focus node
// value: selectedCarType,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ), // Proper padding
// ),
// onChanged:
// purposeList.isNotEmpty
// ? (newValue) {
// setState(() {
// selectedCarType = newValue;
// });
// print(
// "Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
// );
// }
// : null,
//
// items: dropdownItems,
// ),
// ),
// ),
CustomTextFieldItnerarySubWrapper( CustomTextFieldItnerarySubWrapper(
isFocused: _toFocus, isFocused: _toFocus,
isDesktop: isDesktop, isDesktop: isDesktop,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( width: double.infinity,
focusNode: _toFocusNode, // Assign the correct focus node child: DropdownSearch<Map<String, dynamic>>(
value: selectedCarType, // focusNode: _taxiReqFocusNode,
style: TextStyle(fontSize: 12), items: purposeList.cast<Map<String, dynamic>>(),
decoration: InputDecoration( selectedItem: purposeList.firstWhere(
border: InputBorder.none, (item) => item['dropdown_key'] == selectedCarType,
contentPadding: EdgeInsets.symmetric( orElse: () => {},
horizontal: 10,
), // Proper padding
), ),
itemAsString: (item) => item['dropdown_value'] ?? '',
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select ",
style: GoogleFonts.poppins(
color: Colors.grey,
fontSize: 13,
),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
);
},
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (newValue) { ? (newValue) {
setState(() { setState(() {
selectedCarType = newValue; selectedCarType = newValue as String?;
}); });
print( print(
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}", "Updating form data: -> ${newValue ?? ""}",
); );
} }
: null, : null,
items: dropdownItems,
), ),
), ),
), ),
@ -429,38 +505,117 @@ class _TaxiScreenState extends State<TaxiScreen> {
dropdownItems.isNotEmpty ? dropdownItems.first.value : null; dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
return [ return [
CustomTextFieldWrapper( // CustomTextFieldWrapper(
// isFocused: _taxiReqFocused,
// isDesktop: isDesktop,
// width:
// isDesktop
// ? MediaQuery.of(context).size.width * 0.34
// : MediaQuery.of(context).size.width * 0.66,
// child: SizedBox(
// height: 40,
// child: DropdownButtonFormField<String>(
// focusNode: _taxiReqFocusNode, // Assign the correct focus node
// value: selectedReqTaxi,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ), // Proper padding
// ),
// onChanged:
// purposeList.isNotEmpty
// ? (newValue) {
// setState(() {
// selectedReqTaxi = newValue;
// });
// print(
// "Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
// );
// }
// : null,
//
// items: dropdownItems,
// ),
// ),
// ),
CustomTextFieldItnerarySubWrapper(
isFocused: _taxiReqFocused, isFocused: _taxiReqFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
width: width:
isDesktop isDesktop
? MediaQuery.of(context).size.width * 0.34 ? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.66, : MediaQuery.of(context).size.width * 0.66,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( width: double.infinity,
focusNode: _taxiReqFocusNode, // Assign the correct focus node child: DropdownSearch<Map<String, dynamic>>(
value: selectedReqTaxi, // focusNode: _taxiReqFocusNode,
style: TextStyle(fontSize: 12), items: purposeList.cast<Map<String, dynamic>>(),
decoration: InputDecoration( selectedItem: purposeList.firstWhere(
border: InputBorder.none, (item) => item['dropdown_key'] == selectedReqTaxi,
contentPadding: EdgeInsets.symmetric( orElse: () => {},
horizontal: 10,
), // Proper padding
), ),
itemAsString: (item) => item['dropdown_value'] ?? '',
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select ",
style: GoogleFonts.poppins(
color: Colors.grey,
fontSize: 13,
),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
);
},
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (newValue) { ? (newValue) {
setState(() { setState(() {
selectedReqTaxi = newValue; selectedReqTaxi = newValue as String?;
}); });
print( print(
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}", "Updating form data: -> ${newValue ?? ""}",
); );
} }
: null, : null,
items: dropdownItems,
), ),
), ),
), ),
@ -765,7 +920,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Comments *", "Comments",
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,

View File

@ -592,34 +592,104 @@ class _TrainScreenState extends State<TrainScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldItnerarySubWrapper( // CustomTextFieldItnerarySubWrapper(
// isFocused: _isHotelNameFocused,
// isDesktop: isDesktop,
// // width: isDesktop
// // ? MediaQuery.of(context).size.width * 0.34
// // : MediaQuery.of(context).size.width * 0.66,
// child: SizedBox(
// height: 40,
// child: DropdownButtonFormField<String>(
// focusNode: _hotelNameFocusNode, // Assign the correct focus node
// // controller: _hotelNameController,
// value: selectedClass,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ), // Proper padding
// ),
// onChanged:
// purposeList.isNotEmpty
// ? (newValue) {
// setState(() {
// selectedClass = newValue;
// });
// }
// : null,
// items: dropdownItems,
// ),
// ),
// ),
CustomTextFieldWrapper(
isFocused: _isHotelNameFocused, isFocused: _isHotelNameFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
// width: isDesktop width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
// ? MediaQuery.of(context).size.width * 0.34
// : MediaQuery.of(context).size.width * 0.66,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( width: double.infinity,
focusNode: _hotelNameFocusNode, // Assign the correct focus node child: DropdownSearch<Map<String, dynamic>>(
// controller: _hotelNameController, items: purposeList.cast<Map<String, dynamic>>(),
value: selectedClass, selectedItem: purposeList.firstWhere(
style: TextStyle(fontSize: 12), (item) => item['dropdown_key'] == selectedClass,
decoration: InputDecoration( orElse: () => {},
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
), // Proper padding
), ),
itemAsString: (item) => item['dropdown_value'] ?? '',
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select ",
style: GoogleFonts.poppins(
color: Colors.grey,
fontSize: 13,
),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
);
},
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (newValue) { ? (Map<String, dynamic>? newValue) {
setState(() { setState(() {
selectedClass = newValue; selectedClass= newValue?['dropdown_key'];
}); print("Selected Purpose: ${selectedClass}");
} });
: null, }
items: dropdownItems, : null,
), ),
), ),
), ),
@ -642,96 +712,158 @@ class _TrainScreenState extends State<TrainScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
// CustomTextFieldItnerarySubWrapper(
// isFocused: _fromFocus,
// isDesktop: isDesktop,
// child: SizedBox(
// height: 40,
// child:
// isCountryLoading
// ? Center(child: CircularProgressIndicator())
// : DropdownSearch<String>(
// // selectedItem: selectedFrom != null
// // ? countryMap[selectedFrom]
// // : null,
// selectedItem:
// selectedFrom != null
// ? countryMap[selectedFrom] // get the display value from code
// : null,
// popupProps: PopupProps.menu(
// menuProps: MenuProps(backgroundColor: Colors.white),
// constraints: BoxConstraints(maxHeight: 230),
// showSearchBox: true,
// searchFieldProps: TextFieldProps(
// decoration: InputDecoration(
// hintText: "Search ...",
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ),
// ),
// ),
// ),
//
// items: countryMap.values.toList(),
//
// dropdownDecoratorProps: DropDownDecoratorProps(
// dropdownSearchDecoration: InputDecoration(
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 5,
// ),
// border: InputBorder.none,
// ),
// ),
// dropdownBuilder:
// (context, selectedItem) => Align(
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem ?? "Select",
// style: TextStyle(fontSize: 12),
// ),
// ),
//
// // onChanged: (String? newValue) {
// // setState(() {
// // // selectedFrom[index] = countryMap.entries
// // // .firstWhere((entry) => entry.value == newValue)
// // // .key;
// //
// // selectedFrom = countryMap.entries
// // .firstWhere((entry) => entry.value == newValue)
// // .key;
// //
// // print(selectedFrom);
// // });
// // },
// onChanged: (String? newValue) {
// setState(() {
// selectedFrom =
// countryMap.entries
// .firstWhere(
// (entry) => entry.value == newValue,
// )
// .key;
// });
// },
// ),
// ),
// // child: SizedBox(
// // height: 40,
// // child: TextField(
// // focusNode: _fromFocusNode,
// // controller: _fromController,
// // style: const TextStyle(fontSize: 12),
// // decoration: const InputDecoration(
// // labelText: "From",
// // labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
// // floatingLabelBehavior: FloatingLabelBehavior.never,
// // border: InputBorder.none,
// // contentPadding: EdgeInsets.symmetric(vertical: 16),
// // ),
// // ),
// // ),
// ),
CustomTextFieldItnerarySubWrapper( CustomTextFieldItnerarySubWrapper(
isFocused: _fromFocus, isFocused: _fromFocus ?? false,
isDesktop: isDesktop, isDesktop: isDesktop,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: child: DropdownSearch<String>(
isCountryLoading selectedItem: countryMap[selectedFrom],
? Center(child: CircularProgressIndicator()) popupProps: PopupProps.menu(
: DropdownSearch<String>( showSearchBox: true,
// selectedItem: selectedFrom != null fit: FlexFit.loose,
// ? countryMap[selectedFrom] constraints: BoxConstraints(maxHeight: 250),
// : null, menuProps: const MenuProps(backgroundColor: Colors.white),
selectedItem: itemBuilder:
selectedFrom != null (context, item, isSelected) => Container(
? countryMap[selectedFrom] // get the display value from code color: Colors.white,
: null, padding: EdgeInsets.symmetric(
popupProps: PopupProps.menu( horizontal: 10,
menuProps: MenuProps(backgroundColor: Colors.white), vertical: 6,
constraints: BoxConstraints(maxHeight: 230), ),
showSearchBox: true, child: Text(
searchFieldProps: TextFieldProps( item,
decoration: InputDecoration( style: GoogleFonts.poppins(fontSize: 11.5),
hintText: "Search ...", ),
contentPadding: EdgeInsets.symmetric( ),
horizontal: 10, searchFieldProps: TextFieldProps(
), decoration: InputDecoration(
), hintText: "Search Role...",
), contentPadding: EdgeInsets.symmetric(horizontal: 10),
), ),
),
items: countryMap.values.toList(), ),
items: countryMap.values.toList(),
dropdownDecoratorProps: DropDownDecoratorProps( dropdownDecoratorProps: DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration( dropdownSearchDecoration: InputDecoration(
contentPadding: EdgeInsets.symmetric( border: InputBorder.none,
horizontal: 10, contentPadding: EdgeInsets.symmetric(horizontal: 1),
vertical: 5, ),
), ),
border: InputBorder.none, dropdownBuilder:
), (context, selectedItem) => Align(
), alignment: Alignment.centerLeft,
dropdownBuilder: child: Text(
(context, selectedItem) => Align( selectedItem ?? "Select ...",
alignment: Alignment.centerLeft, style: GoogleFonts.poppins(
child: Text( fontSize: 12,
selectedItem ?? "Select", color: Colors.black,
style: TextStyle(fontSize: 12), ),
), ),
), ),
onChanged: (String? newValue) {
// onChanged: (String? newValue) { setState(() {
// setState(() { selectedFrom =
// // selectedFrom[index] = countryMap.entries countryMap.entries
// // .firstWhere((entry) => entry.value == newValue) .firstWhere(
// // .key; (entry) => entry.value == newValue,
// )
// selectedFrom = countryMap.entries .key;
// .firstWhere((entry) => entry.value == newValue) });
// .key; },
// ),
// print(selectedFrom);
// });
// },
onChanged: (String? newValue) {
setState(() {
selectedFrom =
countryMap.entries
.firstWhere(
(entry) => entry.value == newValue,
)
.key;
});
},
),
), ),
// child: SizedBox(
// height: 40,
// child: TextField(
// focusNode: _fromFocusNode,
// controller: _fromController,
// style: const TextStyle(fontSize: 12),
// decoration: const InputDecoration(
// labelText: "From",
// labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
// floatingLabelBehavior: FloatingLabelBehavior.never,
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(vertical: 16),
// ),
// ),
// ),
), ),
if (errorMessages["from_station"] != null) ...[ if (errorMessages["from_station"] != null) ...[
SizedBox(height: 5), // Space before error message SizedBox(height: 5), // Space before error message
@ -752,58 +884,120 @@ class _TrainScreenState extends State<TrainScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
// CustomTextFieldItnerarySubWrapper(
// isFocused: _toFocus,
// isDesktop: isDesktop,
// child: SizedBox(
// height: 40,
// child:
// isCountryLoading
// ? Center(child: CircularProgressIndicator())
// : DropdownSearch<String>(
// selectedItem:
// selectedTo != null
// ? countryMap[selectedTo] // get the display value from code
// : null,
// popupProps: PopupProps.menu(
// menuProps: MenuProps(backgroundColor: Colors.white),
// constraints: BoxConstraints(maxHeight: 230),
// showSearchBox: true,
// searchFieldProps: TextFieldProps(
// decoration: InputDecoration(
// hintText: "Search ...",
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ),
// ),
// ),
// ),
// items: countryMap.values.toList(),
// dropdownDecoratorProps: DropDownDecoratorProps(
// dropdownSearchDecoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(horizontal: 1),
// ),
// ),
// dropdownBuilder:
// (context, selectedItem) => Align(
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem ?? "Select",
// style: TextStyle(fontSize: 12),
// ),
// ),
// onChanged: (String? newValue) {
// setState(() {
// selectedTo =
// countryMap.entries
// .firstWhere(
// (entry) => entry.value == newValue,
// )
// .key;
// });
// },
// ),
// ),
// ),
CustomTextFieldItnerarySubWrapper( CustomTextFieldItnerarySubWrapper(
isFocused: _toFocus, isFocused: _toFocus ?? false,
isDesktop: isDesktop, isDesktop: isDesktop,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: child: DropdownSearch<String>(
isCountryLoading selectedItem: countryMap[selectedTo],
? Center(child: CircularProgressIndicator()) popupProps: PopupProps.menu(
: DropdownSearch<String>( showSearchBox: true,
selectedItem: fit: FlexFit.loose,
selectedTo != null constraints: BoxConstraints(maxHeight: 250),
? countryMap[selectedTo] // get the display value from code menuProps: const MenuProps(backgroundColor: Colors.white),
: null, itemBuilder:
popupProps: PopupProps.menu( (context, item, isSelected) => Container(
menuProps: MenuProps(backgroundColor: Colors.white), color: Colors.white,
constraints: BoxConstraints(maxHeight: 230), padding: EdgeInsets.symmetric(
showSearchBox: true, horizontal: 10,
searchFieldProps: TextFieldProps( vertical: 6,
decoration: InputDecoration( ),
hintText: "Search ...", child: Text(
contentPadding: EdgeInsets.symmetric( item,
horizontal: 10, style: GoogleFonts.poppins(fontSize: 11.5),
), ),
), ),
), searchFieldProps: TextFieldProps(
), decoration: InputDecoration(
items: countryMap.values.toList(), hintText: "Search ...",
dropdownDecoratorProps: DropDownDecoratorProps( contentPadding: EdgeInsets.symmetric(horizontal: 10),
dropdownSearchDecoration: InputDecoration( ),
border: InputBorder.none, ),
contentPadding: EdgeInsets.symmetric(horizontal: 1), ),
), items: countryMap.values.toList(),
), dropdownDecoratorProps: DropDownDecoratorProps(
dropdownBuilder: dropdownSearchDecoration: InputDecoration(
(context, selectedItem) => Align( border: InputBorder.none,
alignment: Alignment.centerLeft, contentPadding: EdgeInsets.symmetric(horizontal: 1),
child: Text( ),
selectedItem ?? "Select", ),
style: TextStyle(fontSize: 12), dropdownBuilder:
), (context, selectedItem) => Align(
), alignment: Alignment.centerLeft,
onChanged: (String? newValue) { child: Text(
setState(() { selectedItem ?? "Select ",
selectedTo = style: GoogleFonts.poppins(
countryMap.entries fontSize: 12,
.firstWhere( color: Colors.black,
(entry) => entry.value == newValue, ),
) ),
.key; ),
}); onChanged: (String? newValue) {
}, setState(() {
), selectedTo =
countryMap.entries
.firstWhere(
(entry) => entry.value == newValue,
)
.key;
});
},
),
), ),
), ),
if (errorMessages["to_station"] != null) ...[ if (errorMessages["to_station"] != null) ...[

View File

@ -457,26 +457,86 @@ class _VisaScreenState extends State<VisaScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldWrapper( // CustomTextFieldWrapper(
// isFocused: _isHotelNameFocused,
// isDesktop: isDesktop,
// // width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
// width:
// isDesktop
// ? MediaQuery.of(context).size.width * 0.34
// : MediaQuery.of(context).size.width * 0.66,
// child: SizedBox(
// height: 40,
// child: DropdownSearch<String>(
// selectedItem: countryMap[selectedCountry],
// popupProps: PopupProps.menu(
// showSearchBox: true, // Enables search functionality
// searchFieldProps: TextFieldProps(
// decoration: InputDecoration(
// hintText: "Search ...",
// contentPadding: EdgeInsets.symmetric(horizontal: 10),
// ),
// ),
// ),
// items: countryMap.values.toList(),
// dropdownDecoratorProps: DropDownDecoratorProps(
// dropdownSearchDecoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(horizontal: 1),
// ),
// ),
// dropdownBuilder:
// (context, selectedItem) => Align(
// // Center-align selected item
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem ?? "Select ",
// style: TextStyle(fontSize: 12),
// ),
// ),
// onChanged: (String? newValue) {
// setState(() {
// // Find the country_code based on selected country_name
// selectedCountry =
// countryMap.entries
// .firstWhere((entry) => entry.value == newValue)
// .key;
//
// if (selectedCountry!.isNotEmpty) {
// errorMessages.remove("country_code");
// }
// });
// },
// ),
// ),
// ),
CustomTextFieldItnerarySubWrapper(
isFocused: _isHotelNameFocused, isFocused: _isHotelNameFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
// width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, width: isDesktop
width: ? MediaQuery.of(context).size.width * 0.34
isDesktop : MediaQuery.of(context).size.width * 0.66,
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.66,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownSearch<String>( child: DropdownSearch<String>(
selectedItem: countryMap[selectedCountry], selectedItem: countryMap[selectedCountry],
popupProps: PopupProps.menu( popupProps: PopupProps.menu(
showSearchBox: true, // Enables search functionality showSearchBox: true,
searchFieldProps: TextFieldProps( searchFieldProps: TextFieldProps(
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Search ...", hintText: "Search ...",
contentPadding: EdgeInsets.symmetric(horizontal: 10), contentPadding: EdgeInsets.symmetric(horizontal: 10),
), ),
), ),
itemBuilder: (context, item, isSelected) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
child: Text(
item,
style: TextStyle(fontSize: 12,color: Colors.black,),
),
);
},
), ),
items: countryMap.values.toList(), items: countryMap.values.toList(),
dropdownDecoratorProps: DropDownDecoratorProps( dropdownDecoratorProps: DropDownDecoratorProps(
@ -485,26 +545,19 @@ class _VisaScreenState extends State<VisaScreen> {
contentPadding: EdgeInsets.symmetric(horizontal: 1), contentPadding: EdgeInsets.symmetric(horizontal: 1),
), ),
), ),
dropdownBuilder: dropdownBuilder: (context, selectedItem) => Align(
(context, selectedItem) => Align( alignment: Alignment.centerLeft,
// Center-align selected item child: Text(
alignment: Alignment.centerLeft, selectedItem ?? "Select",
child: Text( style: TextStyle(fontSize: 12),
selectedItem ?? "Select ", ),
style: TextStyle(fontSize: 12), ),
),
),
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
// Find the country_code based on selected country_name selectedCountry = countryMap.entries
selectedCountry = .firstWhere((entry) => entry.value == newValue)
countryMap.entries .key;
.firstWhere((entry) => entry.value == newValue)
.key;
if (selectedCountry!.isNotEmpty) {
errorMessages.remove("country_code");
}
}); });
}, },
), ),
@ -530,38 +583,116 @@ class _VisaScreenState extends State<VisaScreen> {
), ),
), ),
SizedBox(height: 5), SizedBox(height: 5),
// CustomTextFieldWrapper(
// isFocused: _tripTypeFocused,
// isDesktop: isDesktop,
// width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
// // width: isDesktop
// // ? MediaQuery.of(context).size.width * 0.34
// // : MediaQuery.of(context).size.width * 0.66,
// child: SizedBox(
// height: 40,
// child: DropdownButtonFormField<String>(
// focusNode: _tripTypeFocusNode, // Assign the correct focus node
// value: selectedPurpose,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding: EdgeInsets.symmetric(
// horizontal: 10,
// ), // Proper padding
// ),
// onChanged:
// purposeList.isNotEmpty
// ? (newValue) {
// setState(() {
// selectedPurpose = newValue;
// });
// print(
// "Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
// );
// }
// : null,
//
// items: dropdownItems,
// ),
// ),
// ),
CustomTextFieldWrapper( CustomTextFieldWrapper(
isFocused: _tripTypeFocused, isFocused: _tripTypeFocused,
isDesktop: isDesktop, isDesktop: isDesktop,
width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
// width: isDesktop
// ? MediaQuery.of(context).size.width * 0.34
// : MediaQuery.of(context).size.width * 0.66,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( width: double.infinity,
focusNode: _tripTypeFocusNode, // Assign the correct focus node child: DropdownSearch<Map<String, dynamic>>(
value: selectedPurpose, items: purposeList.cast<Map<String, dynamic>>(),
style: TextStyle(fontSize: 12), selectedItem: purposeList.firstWhere(
decoration: InputDecoration( (item) => item['dropdown_key'] == selectedPurpose,
border: InputBorder.none, orElse: () => {},
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
), // Proper padding
), ),
itemAsString: (item) => item['dropdown_value'] ?? '',
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select ",
style: GoogleFonts.poppins(
color: Colors.grey,
fontSize: 13,
),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
),
);
},
// focusNode: _tripTypeFocusNode, // Assign the correct focus node
// value: selectedPurpose,
// style: TextStyle(fontSize: 12),
// decoration: InputDecoration(
// border: InputBorder.none,
// contentPadding:
// EdgeInsets.symmetric(horizontal: 10), // Proper padding
// ),
onChanged: onChanged:
purposeList.isNotEmpty purposeList.isNotEmpty
? (newValue) { ? (Map<String, dynamic>? newValue) {
setState(() { setState(() {
selectedPurpose = newValue; selectedPurpose= newValue?['dropdown_key'];
}); print("Selected Purpose: ${selectedPurpose}");
print( });
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}", }
); : null,
}
: null,
items: dropdownItems,
), ),
), ),
), ),

View File

@ -1494,7 +1494,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
if (pickedDate != null) { if (pickedDate != null) {
_selectedDateOfExpiry = pickedDate; _selectedDateOfExpiry = pickedDate;
controllers["dateOfExpiry"]?.text = DateFormat( controllers["dateOfExpiry"]?.text = DateFormat(
"yyyy-MM-dd", "dd-MM-yyyy",
).format(pickedDate); ).format(pickedDate);
} }