Home > Software design >  The argument type 'BorderRadius?' can't be assigned to the parameter type 'Borde
The argument type 'BorderRadius?' can't be assigned to the parameter type 'Borde

Time:02-21

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))

CodePudding user response:

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))
  • Related