// Dropdown Field import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:flutter/material.dart'; import '../theme/colors.dart'; class DropdownField extends StatelessWidget { late String hint; late T? value; late IconData? icon; late List? items; late ValueChanged? onChanged; late bool isEnabled; final String keyName = "dropdown_field"; DropdownField({ required this.hint, this.value, this.icon, this.items, this.onChanged, this.isEnabled = true, }); @override Widget build(BuildContext context) { return Container( height: 54.h, margin: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( color: const Color(0xFFF4F5F7), borderRadius: BorderRadius.circular(13), ), child: Row( children: [ if (icon != null) Icon(icon, color: mainPurple), if (icon != null) SizedBox(width: 8.h), Expanded( child: items != null ? DropdownButton( value: value, isExpanded: true, icon: const Icon(Icons.keyboard_arrow_down_rounded, color: mainPurple), underline: const SizedBox(), items: items! .map( (item) => DropdownMenuItem( value: item, child: item.toString().toText15(isBold: true), ), ) .toList(), hint: hint.toText15(color: Colors.black45), onChanged: onChanged, ) : Text( value?.toString() ?? hint, style: TextStyle( color: value != null ? Colors.black : Colors.black45, fontWeight: value != null ? FontWeight.bold : FontWeight.normal, fontSize: 15, ), ), ), ], ), ); } }