티스토리 뷰
플러터의 Listview 종류들 (Types of Listviews in Flutter)
목차:
- 1. ListView
- 2. ListView.builder
- 3. GroupedListView
- 4. GridView
- 5. SingleChildScrollView
- 6. ListTile
- 7. CustomScrollView
플러터에서는 여러가지 Listview를 제공하여 강력한 UI 서비스를 구축할 수 있게끔 해줍니다.
먼저 플러터 공식문서의 coockbook을 참고 해봐요.
https://flutter.dev/docs/cookbook
플러터에서 대표적으로 많이 쓰는 Listview 들을 다뤄보겠습니다.
1. ListView : is for when you have a relatively small and fixed set of items. This is because you create all of the Widgets at once and they are all inserted into the tree.
- 적은 리스트 셋을 가지고 코드들을 다 때려 넣을 때 쓰는 위젯.
2. ListView.builder : is for when you have a large set of items because it doesn't build all of them at once, and only builds the ones that are visible or are going to be visible. This makes it more memory efficient than the regular ListView.
- 리스트 셋이 길어서 메모리 효율을 할 때 쓰는 위젯.
<두개의 가장 큰 차이점>:
ListView() — Render all the items in the list, even if it is not visible.
ListView.Builder()` — Render only visible items on the screen.
3. GroupedListView: Listview 와 비슷하나 크게 아래의 2가지 기능을 가지고 싶을 때 쓰는 위젯.
패키지를 따로 추가해주어야 한다.
- Can be separated into groups of all list item.
- Can give one header for each group
https://pub.dev/packages/grouped_list
자세한 사항은 미디엄의 이 사람의 글을 참고하자
https://medium.com/flutterdevs/grouped-listview-in-flutter-a3a7cc13133c
4. GridView:
The main difference between ListView and GridView is how it lays out its child. With ListView you are laying your children one by one either vertically or horizontally only. With GridView, its a combination of both. It lays its children horizontally first. When it exceeds the number specified in crossAxisCount which is the number of children in the cross axis, it proceeds to lay its next children to a new line.
리스트뷰는 수직이나 수평으로 리스트를 생성한다.
그리드뷰는 두가지 모두인데, 일단은 수평으로 리스트를 생성하고, 명시된 crossAxisCount의 갯수를 초과하게 되면 다음 라인에 리스트 라인을 만들어 배열한다.
자세한 사항은 아래의 미디엄 글을 참고하자
https://medium.com/flutterfly-tech/flutter-listview-gridview-ce7177812b1d
5. SingleChildScrollView: Column에 scrollable functionality을 추가해준다. Wrap column with SCSV
The column is used when we have to list widgets vertically on the screen and SingleChildScrollView widget provides scroll functionality for Column widgets.
SCSV랑 Column이랑 같이 쓰게 되면, 리스트 아이템들이 전부다 렌더링이 된다.
언제 사용하나?!
1. ListView에 비해서 performance가 떨어지기 때문에 적은 리스트이고 성능상 큰 문제가 없을 때 사용
2. 다른 위젯들이 복합적으로 필요하고 스크롤링 기능이 필요할 때 사용.
ListView와의 차이점:
1. ListView는 SCSV + Column 의 최적화라고 보면 된다.
2. ListView는 less flexible 하다. 적은 아이템들로 복잡한 레이아웃이 필요하고 성능이 문제되지 않을 때는 SCSV + Column 사용
6. ListTile : ListView의 children으로 사용된다.
리스트 뷰안에 있는 아이템들을 customizing 할 때 사용한다.
Row에 divider 들을 추가하고 싶으면 ListTile.divideTitles을 사용한다.
7. CustomScrollView: Allows you to add Slivers directly to achieve custom scroll effts.
A sliver is a portion of a scrollable area that you can define to behave in a special way.
A customscrollview has a property slivers which is a list of widgets. Each of the widgets must produce rednersliver otherwise you will get a runtime error.
sliver 을 이용해서 뭔가 커스텀한 스크롤링 효과를 주과 싶을 때 사용한다.
'개발 > Flutter' 카테고리의 다른 글
- Total
- Today
- Yesterday
- flutter listviews #flutter
- flutter #localization #flutterlocalization
- 매빅미니2 #촬여용 드론 #드론 #mavic mini2
- flutter #ios #android #smsautofill
- 드론 #초경량비행장치 #비행 #항공 #드론자격증 #드론1종
- 정부정책 #청년정책 #정부청년지원 #경기도청년지원
- 드론구술시험 #초경량비행장치1종 구술시험
- 공공데이터 청년인턴 #공공데이터 #알바 #공공데이터 청년인턴 후기
- 조종사 #국토부 조종사 #조종사 수급상황 #항공기 조종사 #항공기 당 조종사 비율 #국적항공사 조종사 수
- 쿠팡이츠 배달파트너 #배민컨넥트 #자전거배달 #로드자전거배달 #직장인 부수입 #부업 #알바
- 실업급여
- #저작권보호원 #저작권보호원 면접 #저작권보호원 2차 #디지털 알바 #디지털 부업 #저작권 보호원 모니터링 #모니터링알바 #저작권 보호원 청년 #저작권 보호원 청년 모니터링
- 대한항공 신입조종사 모집 #대한항공 조종사 모집
- 드론 #시마x5 #symax5
- flutter #flutter background service
- flutter #firebase #개발
- ㅂ
- 조종사 #조종사되는법 #
- 영어공부 #TED #TED 영어공부 #3분영어 #영어회화 #영어
- flutter #fluttererror #flutterioserror
- dart
- flutter #udp #flutterudp
- 대한항공 조종사 #대한항공 조종사 채용 #신입조종사 채용 #조종사 채용
- Ted #영어공부 #3분영어 #영어회화 #영어
- 시력 #시력 개선 #눈운동 #조종사 눈건강 #시력회복 #눈 영양제
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |