쥐수의 공부노트
Flutter - ListView 사용하기 본문
728x90
ListView를 사용하면 가로 방향 혹은 세로 방향으로 여러 위젯들을 배치할 수 있다.
플러터에서 ListView는 GridView와 더불어서 많은 위젯들을 표시할 때 거의 필수적으로 사용되는 위젯이므로 반드시 이해해야 한다.
ListView를 생성하는 4가지 옵션
1. 일반적인 ListView를 명시적으로 호출하고 children를 전달하는 방법 => 적은 데이터에 사용시 용이하다.
2. ListView.builder 를 사용하여 동적으로 호출하는 방법 => 많은 양의 데이터 리스트에 용이하고, index도 사용 가능하다.
3. ListView.separated는 2번에 구분선 사용이 가능하다.
4. ListView.custom 사용
해당 코드는 전체 코드가 아닙니다!
body: ListView(
scrollDirection: Axis.horizontal, // 기본값은 vertical !
children: [
postContainer(title:"Title 1",colorData: Colors.blue),
postContainer(title:"Title 2",colorData: Colors.green),
postContainer(title:"Title 3",colorData: Colors.pink),
postContainer(title:"Title 4",colorData: Colors.purple),
postContainer(title:"Title 5",colorData: Colors.blueGrey)
]
),
해당 글의 전체 코드 : https://github.com/land-waters/flutter-study/blob/chap05/flutter_application_1/lib/main.dart
flutter-study/flutter_application_1/lib/main.dart at chap05 · land-waters/flutter-study
Contribute to land-waters/flutter-study development by creating an account on GitHub.
github.com
728x90
'flutter-study' 카테고리의 다른 글
Flutter - GridView 사용하기 (0) | 2024.07.03 |
---|---|
Flutter - ListView 효율적으로 사용하기 (0) | 2024.07.02 |
Flutter - GestureDetector 사용하여 터치 감지하기 (0) | 2024.07.01 |
Flutter - Stack을 사용하여 여러 위젯 중첩하기 (0) | 2024.07.01 |
Flutter - Column, Row 테이블 구성 (0) | 2024.07.01 |