본문 바로가기
개인자료실

Flutter TextField 일단 알아야할 것

by 다겸란이 2023. 7. 14.

column

세로방향으로 여러 위젯을 나열할 때 사용. row 는 가로방향으로 여러 위젯 나열

내가 생각했을 때 이거 칸 잘 계산하기!_(확인) row 는 밑에 따라오는게 무엇이냐

column 은 children [] 이게 생긴다.자동으로 생겼다.

이때 text 는 위젯이었다.

위젯에서 전구모양/ 단축키 (ctrl + . )/마우스오른쪽 refactor \

에서 Wrap with column 선택했다.

 

Textfield () 이 위젯(?)은 무언가 입력하게끔 해주는 위젯(?) 함수(?) 

textfiield() 는 이렇게만 쳐도 오류는 안생긴다.

그냥 화면에 줄이 생긴형태. 이 줄 위를 누르면 Text 를 입력이 가능해진다.

줄만 있으면 헷갈리니깐

decoration 속성(?)  꾸미는 방법

decoration: , 이런 형식으로 나와지고, 이것은 변수(?) 같다. 

여러 항목중에 InputDecoration() 이 들어와진다. 얘도 () 가 꼭 필요하다. 

꾸미기에 다양한 방법

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                label: Text("dd"),
              ),

이방법도 있고, 

TextField(
              decoration: InputDecoration(
                labelText: ("dd"),
              ),

같은 화면이 뜬다. 일단 보여지는 것 같다. 기본색상이 왜 파랑색일까???

label: Text ("제목같은 것적자")

labelText : ("제목같은 것적자")

 

 

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                  hintText: 'hint',
                  helperText: 'helper',
                  labelText: 'label',
                  counterText: 'counter'),
            )

글자 그대로 대입해서 어디 위치인지 파악완료! 

hint 는 글자 입력하면 보이지 않게 되었다.

 

 

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                labelText: ("dd"),
                hintText: "이메일",
                labelStyle: TextStyle(
                  color: Colors.black,
                ),

labelStyle: TextStyle(color: Colors.black)

이것을 적으면 글 그대로 dd 부분이 검은색으로 변했다.

label 은 이걸로 끝.

 

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                labelText: ("dd"),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.all(
                    Radius.circular(3),
                  ),

border 이라는 것인데. 중간에 빼먹으니깐 적용이 되지 않았다. 일단 형태는 박스형태로 line 을 그려주는 것 같다.

맨 뒤에 숫자를 내가 변경하니 사각형의 맨 꼭지점들에 라운드가 들어갔다. 

TextField(
              decoration: InputDecoration(
                labelText: ("dd"),
                border: OutlineInputBorder(
                  borderRadius: BorderRadius.all(
                    Radius.circular(
                      50,
                    ),
                  ),

라운드 확실하게 보이는 모습. Radius 뒤에 몇가지가 있는데 그다지 이것만 사용할 것 같다. 

 

 

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                labelText: "배경색넣기",
                filled: true,
                fillColor: Colors.blue.shade100,
                enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide.none,
                ),
              ),
            )

사진처럼 배경색이 똬악 넣어졌다.

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                labelText: "배경색넣기",
                filled: true,
                fillColor: Colors.blue.shade100,
              ),
            ),
            TextField(
              decoration: InputDecoration(
                filled: false,
                fillColor: Colors.blue.shade100,
                enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide.none,
                ),
              ),
            ),

 

보시다시피 같은 배경색 채우기 이지만,

filled: 를 boolean(true, false) 에 따라서  색이 넣었다 뺏다. 가능하다.

enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide.none,
                ),

 이부분을 없애니 밑줄이 생겼다.  그러니깐 이 코드는 밑줄제거한다.

OutlineInputBorder() : 상하좌우 테두리 _(확인) 정확히 어떻게 되는지는 아직 모른다. 나중에 보자

UnderlineInputBorder() : 하단 테두리 _(확인) 정확히 어떻게 되는지는 아직 모른다. 나중에 보자

InputBorder.none : 테두리 없앰. _(확인) 정확히 어떻게 되는지는 아직 모른다. 나중에 보자

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                icon: Icon(
                  Icons.star,
                ),
              ),
            ),

보시다 시피 아이콘을 넣는 방법.

InputDecoration( 여기 파라미터(불러오는 값) 넣는 곳에 

prefixIcon, suffixIcon 도 있는데. 이것은 아직 사용법을 모르겠다._(확인) 처음보는 것들 어떤 건지 확인하기

 

 

 

 

 

TextField(
              obscureText: true,
              decoration: InputDecoration(
                labelText: "비밀번호",
              ),
            ),

비밀번호 같은 것은 가려야지.

obscureText: true -> 숨겨지는 것

obscureText: false -> 보여짐

obscureText: 는 숨길때만 사용해야겠다.

 

 

 

 

 

TextField(
              decoration: InputDecoration(
                enabledBorder: OutlineInputBorder(
                  borderSide: BorderSide(
                    color: Colors.green,
                    width: 1.0,
                  ),//borderSide
                ),//OutlineInputBorder
              ),//InputDecoration
            ),//textField

드디어 찾았다. 색상이 변한것이 보이는가 테두리에 색상 넣는 법. borderSide 화면 확인되는 것.

 

 

테두리 관련 파라미터(불러오는 값들) 

  • border:
  • focusedBorder:
  • disabledBorder:
  • errorBorder:
  • focusedErrorBorder:

이상으로 일단 textfield 는 그만.

'개인자료실' 카테고리의 다른 글

추상화클래스 Abstract  (0) 2023.07.27
print(), readLine()  (0) 2023.07.16