programing

Flutter : HintText가 있지만 밑줄이없는 TextField를 만드는 방법은 무엇입니까?

kingscode 2021. 1. 17. 10:59
반응형

Flutter : HintText가 있지만 밑줄이없는 TextField를 만드는 방법은 무엇입니까?


이것이 내가 만들려고하는 것입니다.

여기에 이미지 설명 입력

텍스트 필드에 대한 Flutter 문서 ( https://flutter.io/text-input/ ) null에서 장식 으로 전달하여 밑줄을 제거 할 수 있다고 말합니다 . 그러나 그것은 또한 힌트 텍스트를 제거합니다.

텍스트 필드의 포커스 여부에 관계없이 밑줄을 원하지 않습니다.

업데이트 : 분명히 이것은 사용하여 쉽게 할 수 있습니다.

new InputDecoration.collapsed(...),

테두리를 그리지 않고 힌트를 유지합니다.


다음과 같이하십시오.

TextField(
  decoration: new InputDecoration.collapsed(
    hintText: 'Username'
  ),
),

또는 아이콘과 같은 다른 항목이 필요한 경우 테두리를 InputBorder.none

InputDecoration(
    border: InputBorder.none,
    hintText: 'Username',
  ),
),

초점을 맞춘 테두리를 없음으로 변경

TextField(
      decoration: new InputDecoration(
          border: InputBorder.none,
          focusedBorder: InputBorder.none,
          contentPadding: EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
          hintText: 'Subject'
      ),
    ),

참조 URL : https://stackoverflow.com/questions/49040679/flutter-how-to-make-a-textfield-with-hinttext-but-no-underline

반응형