본문 바로가기
프로그래밍/Flutter & Dart

[Flutter] 자잘한 것들

by 소꿍 2021. 8. 15.

Flutter 공부하면서 알게되는 자잘한 것들 정리

 

  • children: <Widget>[]와 children: []의 차이?
    전자는 List에 들어가는 type을 Widget으로 명시해 준 것, 후자는 dynamic

  • obscureText: true or false(true는 가리기)
    Whether to hide the text being edited (e.g., for passwords).
    default는 false, not null
    https://api.flutter.dev/flutter/widgets/EditableText/obscureText.html

  • $로 변수 사용 가능
    2단계 이상 depth의 변수 사용 시에는 ${}를 사용한다.
    print('$counters');
    
    // 2단계 이상의 depth
    print('${Human.height}');​

 

  • String 관련
    isEmpty - Whether this string is empty, result type is bool(true=비었다)
    isNotEmpty - Whether this string is not empty.(true=안 비었다)

  • getStringList - return string list from data
    return type은 Future<List<String>>

  • border style 설정
    // TextFormField
    decoration: InputDecoration(
    border: OutlineInputBorder(
    borderRadius: BorderRadius.all(Radius.circular(8.0)),
           borderSide: BorderSide.none,
        ),
    
    // TextButton
    child: TextButton(
        style: TextButton.styleFrom(
        shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.all(Radius.circular(8.0)),
       ),
    ),​


  • TextField, TextFormField의 차이
    TextFormField는 form에 사용하는데 입력값의 유효성 검증, 다른 Form과의 연동 등의 기능이 제공된다.

  • double.infinity
    width나 height: double.infinity를 쓰면 parent의 최대 size로 child의 크기를 설정한다.

  • setState, this.setState 차이
    From the docs setState is a method for state class, since Stateful widget's state class extends State, you can call a classes method using this or directly. And in general, this.var is the same as calling var unless you have another variable with the same name inside your scope.

  • mounted, this.mounted - 따로 정리하기
    https://jaceshim.github.io/2019/01/28/flutter-study-stateful-widget-lifecycle/
  • AppBar - actions 속성
    위젯 title 다음 행에 표시할 위젯 목록 리스트 []

  •  

댓글