renderSelect method
Implementation
Widget renderSelect() {
final bool isMobileMediaQuery = isMobileView(context);
return DropdownButtonFormField(
focusNode: focusNode,
itemHeight: 50,
isDense: false,
isExpanded: isMobileMediaQuery,
padding: const EdgeInsets.all(0),
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.3)),
),
errorBorder: const OutlineInputBorder(
borderSide: BorderSide(width: 1, color: cancelColor),
),
focusedErrorBorder: const OutlineInputBorder(
borderSide: BorderSide(width: 1, color: cancelColor),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Theme.of(context).colorScheme.onSurface),
),
disabledBorder: const OutlineInputBorder(
borderSide: BorderSide(width: 1, color: Colors.grey),
),
errorStyle: const TextStyle(color: cancelColor, fontSize: 12),
),
value: value,
items: items,
style: Theme.of(context).textTheme.bodyMedium,
dropdownColor: Colors.white,
onTap: () {
// FocusScope.of(context).requestFocus(FocusNode());
},
onChanged: (Object? value) {
// FocusScope.of(context).requestFocus(FocusNode());
if (!disabled) {
onChanged(value.toString());
}
},
validator: (value) {
if (isMandatory == true && value == null) {
focusNode.requestFocus();
return 'Merci de sélectionner une option';
}
return null;
},
);
}