[Flutter] TextField hintText (Placeholder) 폰트, 컬러 변경하기

kimdocs...📄·2023년 11월 27일
0

flutter

목록 보기
15/30

  Widget build(BuildContext context) {
    return TextField(
      focusNode: widget.focusNode,
      controller: widget.controller,
      decoration: InputDecoration(
        hintText: widget.hintText,
        hintStyle: TextStyle(
          color: Colors.red,
          fontSize: 16,
        ),
        focusedBorder: UnderlineInputBorder(
          borderSide: BorderSide(color: borderColor), // 동적 border 색상
        ),
      ),
      onChanged: (value) {
        setState(() {
          borderColor =
              value.isEmpty ? CGColor.secondary_2nd : CGColor.primary_2nd;
        });
      },
    );
  }

TextField 속성에 hitText와 hintStyle을 지정해주면 된다.

profile
👩‍🌾 GitHub: ezidayzi / 📂 Contact: ezidayzi@gmail.com

0개의 댓글