본문 바로가기

flutter10

[Flutter] AppBar의 title 왼쪽으로 정렬하기 AppBar의 centerTitle property를 false 로 설정한다. return Scaffold( appBar: AppBar( centerTitle: false, // 여기 title: Text('TITLE'), ), ... - 참고한 글 https://stackoverflow.com/questions/58913303/how-to-place-appbar-title-in-left-side-in-flutter 2022. 11. 24.
[Flutter] Single-child layout / Multi-child layout / Silver Widgets 위젯 중에 어떤 위젯은 child(Single-child), 어떤 위젯은 children(Multi-child)를 가지는데, 아직 Flutter가 익숙하지 않다 보니 헷갈리는 경우가 있어 이를 정리해 보았다. 참고한 Flutter docs에 각 widget의 설명으로 연결되는 링크가 있어 보기 편한 것 같다. Single-child layout widgets Align AspectRatio Baseline Center ConstrainedBox Container CustomSingleChildLayout Expanded FittedBox FractionallySizedBox IntrinsicHeight IntrinsicWidth LimitedBox Offstage OverflowBox Padding Si.. 2021. 8. 15.
[Flutter] EdgeInsets class EdgeInsets class padding, margin과 같이 여백을 줄 때 사용한다. EdgeInsets.all - 모든 방향에 같은 값 // all const EdgeInsets.all(8.0); // 모든 방향으로 8pixels의 여백 EdgeInsets.only - 한 방향 // only const EdgeInsets.only(left: 40.0); // 왼쪽에만 40pixels의 여백 EdgeInsets.symmetric - 수직 혹은 수평 // symmetric const EdgeInsets.symmetric( {double vertical = 0.0, double horizontal = 0.0} ) const EdgeInsets.symmetric(vertical: 8.0); // ex. .. 2021. 8. 15.
[Flutter] Class, constructor, property 아래와 같이 Person 클래스를 정의한다고 해 보자. class Person { // property double height; int age = 0; // constructor Person({double startingHeight}) { height = startingHeight; } // method void grow(int numberOfYears) { age = age + numberOfYears; } } Person 클래스는 double 타입의 height과 int 타입의 age를 property로 갖는다. (멤버 변수) 생성자를 선언할 때 {}, named parameter를 사용했는데, this keyword를 사용해 생성자를 선언할 때는 named parameter 적용이 optional.. 2021. 8. 15.
[Flutter/dart] List class List class List는 length와 인덱스 접근이 가능한 콜렉션 Dart의 List class(https://api.dart.dev/stable/2.13.4/dart-core/List-class.html) 에서 필요한 부분을 정리했다. 서브클래스로 Fixed-length list와 Growable list가 있는데, 말 그대로 Fixed-length list는 길이가 고정된 list이고, Growable list는 아이템에 따라 길이가 조정된다. Fixed-length list는 List의 길이를 변경하려고 하면 에러가 발생한다. default는 Growable list이다. List.length - List의 길이 (아래 methods와 달리 property여서 () 없이 사용) List.in.. 2021. 8. 15.