Motivation
카드 위젯을 리스트뷰로 리스팅했을때 하단에 마진을 추가하고 싶은 경우
ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
print(index);
return Container(
margin: EdgeInsets.only(
left: 4,
bottom: list.length - 1 == index ? 15 : 4,
right: 4,
top: 4),
child: ListTile(
tileColor: Colors.grey,
title: Text(list[index].toString()),
),
);
})
인덱스가 마지막인 경우의 마진을 설정함
Reference
How to add bottom margin for the last card in the listview?
How to add bottom margin for the last card in the listview? Currently there is no gap between bottom screen line and the last card in the listview. The listview is placed right in the body section.
stackoverflow.com
728x90
'Flutter' 카테고리의 다른 글
[Flutter / Error] xcode_backend.sh: No such file or directory (0) | 2022.05.23 |
---|---|
[Flutter / GetX] prevent delete controller on route page : 라우트할때 컨트롤러 삭제 방지 (0) | 2022.05.23 |
[Flutter] appbar transparent : 앱 바 색상 없애기 (0) | 2022.05.23 |
[Flutter] zoom in on an image with double tap(extended_image ) : 탭하여 확대하기 (0) | 2022.05.18 |
[Flutter] dismiss page on scroll : 스크롤해서(당겨서) 닫기 (0) | 2022.05.18 |