ListView 선형으로 배열된 위젯 목목을 담고 있는 스크롤 가능한 위젯 주로 사용하는 속성List<Widget> childrenListView 내부에 담길 위젯 목록 기본 값 : const <Widget>[] Axis scrollDirection스크롤 방향 종류Axis.horizontal Axis.vertical 기본 값 : Axis.vertical bool reverse역순 정렬 여부 true일 경우 ListView 내부에서 A → B → C 순으로 배치되던 위젯 목록은 C → B → A 순으로 배치된다. 기본 값 : false ScrollController? controller스크롤을 제어하기 위한 컨트롤러 primary의 값이 true일 경우 controller은 null이어야 한다. bool? primary해당 위젯이 상위 PrimaryScrollController와 연관된 기본 스크롤 뷰인지의 여부 true일 경우 Ios에서 상태 표시줄을 탭하면 맨위로 스크롤된다. ScrollPhysics? physics bool shrinkWraptrue일 경우 ListView는 부모 위젯의 전체 영역을 차지하는 것이 아닌 필요한 공간만 차지하도록 변경된다. 기본 값 : false EdgeInsetsGeometry? padding double? itemExtentnull이 아닐 경우 스크롤 방향으로 지정한 크기를 갖도록 강제한다. double? cacheExtentnull이 아닐 경우 각 항목이 화면 밖에 있어도 지정한 크기에 맞게 미리 빌드된다. Widget? prototypeItem지정한 위젯의 크기만큼 자식 위젯의 크기를 강제한다. Function(int, SliverLayoutDimensions)? itemExtentBuildernull이 아닌 경우 빌더가 반환한 해당 범위를 하위 항목에 강제로 적용한다. DragStartBehavior dragStartBehavior드래그 시작 동작이 처리되는 방식 종류DragStartBehavior.start DragStartBehavior.down 기본 값 : DragStartBehavior.start ScrollViewKeyboardDismissBehavior keyboardDismissBehavior키보드를 자동으로 닫는 방법 종류ScrollViewKeyboardDismissBehavior.manual ScrollViewKeyboardDismissBehavior.onDrag드래그가 시작될 때 자동으로 키보드가 닫힌다. 기본 값 : ScrollViewKeyboardDismissBehavior.manual 참고 ListView (
children: [
Text ( "신" ),
Text ( "호" ),
Text ( "등" ),
]
,)
ListView.builder 하위 항목에 대해서만 빌더가 호출되므로 하위 위젯 수가 많거나 무한한 목록 보기에 적합한 ListView의 생성자 유형 ListView.builder는 랜더링되는 하위 위젯의 개수를 알 수 있어서 ListView에 비해서 랜더림이 빠르다. 주로 사용하는 속성Function(BuildContext, int) itemBuilder int? itemCount ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics bool shrinkWrap EdgeInsetsGeometry? padding double? itemExtent double? cacheExtent Widget? prototypeItem Function(int, SliverLayoutDimensions)? itemExtentBuilder DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 ListView.separated 하위 항목에 대해서만 빌더가 호출되므로 하위 위젯 수가 많거나 무한한 목록 보기에 적합한 ListView의 생성자 유형 ListView.separated는 랜더링되는 하위 위젯의 개수를 알 수 있어서 ListView에 비해서 랜더림이 빠르다. 주로 사용하는 속성Function(BuildContext, int) itemBuilder int? itemCount Widget? Function(BuildContext, int) itemBuilder Widget Function(BuildContext, int) separatorBuilder int itemCount ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics bool shrinkWrap EdgeInsetsGeometry? padding double? itemExtent double? cacheExtent Widget? prototypeItem Function(int, SliverLayoutDimensions)? itemExtentBuilder DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 자식 위젯이 랜더링 가능한 범위를 넘어갈 경우 내부적으로 스크롤할 수 있게 하는 위젯 주로 사용하는 속성Widget? child내부에 배치될 자식 위젯 Row나 Column같은 위젯을 많이 사용한다. ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics EdgeInsetsGeometry? padding DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 SingleChildScrollView (
child: Column (
children: [
Container ( height: 1000 , color: Colors . red ,),
Container ( height: 1000 , color: Colors . yellow ,),
Container ( height: 1000 , color: Colors . green ,),
],),
)
Wrap 내부의 하위 위젯 목록을 가로 또는 세로 방향으로 표시하는 위젯 주로 사용하는 속성List children 내부에 배치될 위젯 목록 기본 값 : const [], Axis direction정렬 방향 종류Axis.horizontal Axis.vertical 기본 값 : Axis.horizontal WrapAlignment alignment내부 요소을 주 축에 배치하는 방법 기본 값 : WrapAlignment.start WrapCrossAlignment crossAxisAlignment내부 요소을 교차 축에 배치하는 방법 기본 값 : WrapCrossAlignment.start double spacing주축을 기준으로 한 내부 위젯 간의 간격Axis.horizontal 기준 Axis.vertical 기준 기본 값 : 0.0 WrapAlignment runAlignment내부 요소을 교차 축에 배치하는 방법 기본 값 : WrapAlignment.start double runSpacing교차축을 기준으로 한 내부 위젯 간의 간격Axis.horizontal 기준 Axis.vertical 기준 기본 값 : 0.0 VerticalDirection verticalDirection세로 기준으로 내부 위젯들을 배치하는 방향 종류VerticalDirection.down VerticalDirection.up 기본 값 : VerticalDirection.down 참고 Container (
width: 500 ,
child: SingleChildScrollView (
child: Wrap (
spacing: 50 ,
runSpacing: 100 ,
children: [
Container ( width: 150 , height: 300 , color: Colors . red ,),
Container ( width: 250 , height: 300 , color: Colors . yellow ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . green ,),
Container ( width: 350 , height: 300 , color: Colors . blue ,),
],
),
),
)
GridView 스크롤 가능한 2차원 위젯 배열 주로 사용하는 속성SliverGridDelegate gridDelegateGridView 내에서 자식의 레이아웃을 제어하는 대리자 필수 List children 내부에 배열될 위젯 목록 기본 값 : const [] ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics bool shrinkWrap EdgeInsetsGeometry? padding double? cacheExtent DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 GridView.builder 빌더 메소드를 사용하여 생성되는 위젯을 통해서 스크롤 가능한 2D 위젯 배열을 만든다. 위젯 수가 많은 경우에 GridView.count보다 성능이 좋다. 주로 사용하는 속성SliverGridDelegate gridDelegateGridView 내에서 자식의 레이아웃을 제어하는 대리자 필수 Widget? Function(BuildContext, int) itemBuilder int? itemCount ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics bool shrinkWrap EdgeInsetsGeometry? padding double? cacheExtent DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 GridView.count 교차축에 고정된 수의 타일을 사용하여 스크롤 가능한 2D 위젯 배열을 만든다. 단일 행의 항목을 계산하는 데 직접 사용할 수 있다. 주로 사용하는 속성int crossAxisCount double mainAxisSpacing double crossAxisSpacing double childAspectRatio위젯의 넓이 비율 childAspectRatio: 가로_비율 / 세로_비율
처럼 작성한다.예시 : childAspectRatio: 1 / 2
기본 값 : 1.0 List children 내부에 배열될 위젯 목록 기본 값 : const [] ListView 생성자 설명 참고 Axis scrollDirection bool reverse ScrollController? controller bool? primary ScrollPhysics? physics bool shrinkWrap EdgeInsetsGeometry? padding double? cacheExtent DragStartBehavior dragStartBehavior ScrollViewKeyboardDismissBehavior keyboardDismissBehavior 참고 GridView . count (
primary: false ,
padding: const EdgeInsets . all ( 20 ),
crossAxisSpacing: 10 ,
mainAxisSpacing: 10 ,
crossAxisCount: 2 ,
children: < Widget >[
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 100 ],
child: const Text ( "He'd have you all unravel at the" ),
),
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 200 ],
child: const Text ( 'Heed not the rabble' ),
),
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 300 ],
child: const Text ( 'Sound of screams but the' ),
),
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 400 ],
child: const Text ( 'Who scream' ),
),
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 500 ],
child: const Text ( 'Revolution is coming...' ),
),
Container (
padding: const EdgeInsets . all ( 8 ),
color: Colors . teal [ 600 ],
child: const Text ( 'Revolution, they...' ),
),
],
)
Table 위젯을 행과 열로 배치한다. 주로 사용하는 속성List children 내부에 배치될 TableRow 위젯 목록 기본 값 : const [] Map<int, TableColumnWidth>? columnWidths TableColumnWidth defaultColumnWidth테이블의 열이 가지는 기본적인 가로 길이 값 기본 값 : const FlexColumnWidth() TextDirection? textDirection TableBorder? border TableCellVerticalAlignment defaultVerticalAlignment기본 값 : TableCellVerticalAlignment.top TextBaseline? textBaseline 참고 Table (
border: TableBorder . all (),
columnWidths: const < int , TableColumnWidth >{
0 : IntrinsicColumnWidth (),
1 : FlexColumnWidth (),
2 : FixedColumnWidth ( 64 ),
},
defaultVerticalAlignment: TableCellVerticalAlignment . middle ,
children: < TableRow >[
TableRow (
children: < Widget >[
Container (
height: 32 ,
color: Colors . green ,
),
TableCell (
verticalAlignment: TableCellVerticalAlignment . top ,
child: Container (
height: 32 ,
width: 32 ,
color: Colors . red ,
),
),
Container (
height: 64 ,
color: Colors . blue ,
),
],
),
TableRow (
decoration: const BoxDecoration (
color: Colors . grey ,
),
children: < Widget >[
Container (
height: 64 ,
width: 128 ,
color: Colors . purple ,
),
Container (
height: 32 ,
color: Colors . yellow ,
),
Center (
child: Container (
height: 32 ,
width: 32 ,
color: Colors . orange ,
),
),
],
),
],
)
TableRow Table 위젯에서 하나의 행을 나타내기 위해 사용한다. 주로 사용되는 속성Decoration? decoration List children 내부에 정렬할 위젯 목록 기본 값 : const [] 참고 TableCell Table 위젯에서 하나의 셀(칸)을 나타내기 위해 사용한다. TableRow 위젯 내부에서 사용된다. 주로 사용되는 속성TableCellVerticalAlignment? verticalAlignment Widget child 참고