개발/Flutter
[Flutter] Container Widget 에 대하여 ..
라보떼
2023. 1. 13. 14:15
Container
일반적인 페인팅, 위치 지정 , 크기 조정의 위젯들을 결합한 형태의 편리한 위젯입니다.
컨테이너를 부모에 두고 색, 모양, 위치 등 여러 형태로 커스텀하기 좋습니다.
Container(
margin: EdgeInsets.all(40),
padding: EdgeInsets.all(20),
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.all(Radius.circular(30))),
child: const Text('this is container'),
)
위 예제는 컨테이너 내부에 child로 text가 들어가 있고 text의 배경을 꾸미는 역활을 하고 있습니다.
이와 같이 내부에 widget을 두고 다양한 프로퍼티를 활용하여 여러 항목들을 만들어가는데 유용한 위젯입니다.
컨테이너의 사이즈를 지정해주지 않으면 기본적으로 Child의 사이즈에 맞춰 생성됩니다.
만약 child가 없는 상태이면 화면의 최대크기로 생성 됩니다.
PROPERTIES
Property | Description | Type |
child | 자식 위젯 | Widget |
alignment | 자식 정렬 | Alignment |
foregroundDecoration | 자식 앞에 적용될 Paint | Decoration |
color | 배경색 | Color |
decoration | 배경이 될 Paint | Decoration |
padding | 내부 공간에 부여할 여백 | EdgeInsets |
margin | 외부 공간에 부여할 여백 | EdgeInsets |
transform | 형태 변경 ( 회전 ) | Matrix4 |
transformAlignment | transform 적용에 따른 상대적인 정렬 | Alignment |
https://api.flutter.dev/flutter/widgets/Container-class.html
Container class - widgets library - Dart API
A convenience widget that combines common painting, positioning, and sizing widgets. A container first surrounds the child with padding (inflated by any borders present in the decoration) and then applies additional constraints to the padded extent (incorp
api.flutter.dev