본문 바로가기
Flutter/Flutter FAQ

Flutter 플러터에서 TextFormField의 입력 텍스트 색상을 변경하는 방법, How to change TextFormField input text color in Flutter

by 베타코드 2023. 9. 29.
반응형

질문


대학에서 플러터 앱의 UI를 만들고 있습니다. TextFormField에 입력된 텍스트를 흰색으로 표시하고 싶습니다. 이는 불필요하게 어렵습니다. 구글링 등을 시도해 보았지만 명확한 답변을 찾을 수 없습니다.

  new Theme(
    // 이는 밑줄의 색상을 지정합니다
    data: theme.copyWith(
      primaryColor: Colors.white,
      hintColor: Colors.transparent,

    ),
    child: new Padding(
      padding: const EdgeInsets.fromLTRB(32.0, 40.0, 32.0, 4.0),
      child: TextFormField(

          key: Key('username'),
          keyboardType: TextInputType.text,
          controller: usernameController,
          decoration: InputDecoration(

              fillColor: Colors.black.withOpacity(0.6),
              filled: true,
              border: new OutlineInputBorder(

                borderRadius: const BorderRadius.all(

                  const Radius.circular(8.0),
                ),
                borderSide: new BorderSide(
                  color: Colors.transparent,
                  width: 1.0,
                ),
              ),
              labelText: '사용자 이름',
              labelStyle:
                  new TextStyle(color: Colors.white, fontSize: 16.0)),
          style:
              TextStyle(fontSize: 20.0, color: textTheme.button.color),
          validator: validateUserName,
          onSaved: (val) => this.loginFields._username = val),
    ),
  ),

답변


다음과 같이 하면 됩니다:

TextFormField(
  style: TextStyle(color: Colors.white),
)
반응형

댓글