Search code examples
flutterdartborder-radius

The argument type 'BorderRadius?' can't be assigned to the parameter type 'BorderRadius' flutter


I am having an InputDecoration which has the border property, If a certain condition is true i apply OutlineInputBorder or else i set it to null which is working correctly. I also want to apply borderRadius if a certain condition is true but i am getting the error The argument type 'BorderRadius?' can't be assigned to the parameter type 'BorderRadius' if i apply the borderRadius without the if statement its just working correctly what might be the issue. Below is my code

decoration: InputDecoration(
                                        labelText:
                                            enableDropDownFormFieldLabelText
                                                ? "Select Car"
                                                : null,
                                        border:
                                            enableCustomizableDropDownFormFieldOutlineInputBorder
                                                ? OutlineInputBorder(
                                                    borderRadius: enableCustomizableDropDownFormFieldOutlineInputBorderBorderRadius
                ? BorderRadius.circular(15): null)
                                                : null,
                                        contentPadding: const EdgeInsets.only(
                                            left: 10, right: 5))


Solution

  • BorderRadius can not be null. Use BorderRadius.circular(0) istead.

    decoration: InputDecoration(
                                        labelText:
                                            enableDropDownFormFieldLabelText
                                                ? "Select Car"
                                                : null,
                                        border:
                                            enableCustomizableDropDownFormFieldOutlineInputBorder
                                                ? OutlineInputBorder(
                                                    borderRadius: enableCustomizableDropDownFormFieldOutlineInputBorderBorderRadius
                ? BorderRadius.circular(15): BorderRadius.circular(0))
                                                : null,
                                        contentPadding: const EdgeInsets.only(
                                            left: 10, right: 5))