skip to Main Content

I can see the color change of enabledBorder and focusedBorder right away, but I can’t see the color change of the border

whole codes

TextField(
  enabled: true,
  decoration: InputDecoration(
    hintText: "영화 제목을 검색해주세요.",
    helperText: 'helper',
    labelText: 'label',
    counterText: 'counter',
    border: OutlineInputBorder(
      borderSide: BorderSide(
        color: Colors.red, // Default border color
      ),
    ),
    enabledBorder: OutlineInputBorder(
      borderSide: BorderSide(
        color: Colors.blue, // 테두리를 투명하게 만듭니다.
      ),
    ),
    focusedBorder: OutlineInputBorder(
      borderSide: BorderSide(
        color: Colors.green, // Border color when focused
      ),
    ),
    suffixIcon: IconButton(
      onPressed: () {},
      icon: Icon(Icons.search),
    ),
  ),
),

I wonder why the color change of the border is invisible and how can I change it

I’ve changed the color of the appbar to be transparent, and I’ve disabled the border

2

Answers


  1. border: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(10)),
      borderSide: BorderSide(
        color: Colors.red, // Default border color
      ),
    ),
    enabledBorder: OutlineInputBorder(
      borderRadius: BorderRadius.all(Radius.circular(10)),
      borderSide: BorderSide(
        width: 1,
        color: Colors.blue, // 테두리를 투명하게 만듭니다.
      ),
    ),
    focusedBorder: OutlineInputBorder(
      borderSide: BorderSide(
        borderRadius: BorderRadius.all(Radius.circular(10)),
        width: 1,
        color: Colors.green, // Border color when focused
      ),
    ),
    

    The radius of the border must be provided and also the width in focusedBorder as well as enabledBorder.

    Login or Signup to reply.
  2. According to the documentation here.

    Only the border’s shape is used. If custom BorderSide values are
    desired for a given state, all four borders – errorBorder,
    focusedBorder, enabledBorder, disabledBorder – must be set.

    If you are trying to set the color of the disabled textfield. Then you should use

    disabledBorder: OutlineInputBorder(
      borderSide: BorderSide(
        color: Colors.yellow, // Default border color
      ),
    ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search