본문으로 바로가기
  1. Home
  2. Flutter/Widget
  3. Flutter ListTile 프로퍼티 문서

Flutter ListTile 프로퍼티 문서

· 댓글개 · Dev_Whale

Flutter에서 ListTile은 자주 사용되는 위젯이라고 생각합니다. 하지만 프로퍼티 이름만 봐도 어떤 동작을 하는지 예상이 가능한 이름도 있지만 자주 사용하지 않고 생소한 이름의 가진 프로퍼티를 정리해보려고 합니다.


프로퍼티 종류

  • visualDensity : ListTile 안에 있는 위젯들 (title, subtitle, trailing... ) 사이의 padding 값
  • isThreeLine : subtitle 3줄 여부
    • default value - false 
    • isThreeLine : true - subtitle의 길이가 3줄이 안되어도 3줄 칸 확보
    • dense : true 일 때 적용되지 않음
  • dense : 위젯의 밀집 여부

dense 적용

  • horizontalTitleGap : trailing과 (title, subtitle) 간격 조절

horizontalTitleGap

  ListTile(
    visualDensity: VisualDensity(vertical: -4, horizontal: 0), // ListTile 안에 있는 위젯사이의 padding 값
    title: Text('VisualDensity'),
    subtitle: Text('vertical: -4, horizontal: 0'),
    leading: CircleAvatar(backgroundImage: NetworkImage(url)),
    trailing: Icon(Icons.more_vert_sharp),
    isThreeLine: true, // subtitle 3칸 확장
    dense: false, // ListTile 에 있는 위젯 밀집 여부 (true : isThreeLine 속성이 적용되지 않는다.)
    selected: false, // 선택 여부
    selectedColor: Colors.teal,
    focusColor: Colors.deepPurpleAccent,
    enabled: true, // 활성화 여부 (false : title,subtitle textColor 가 grey 로 바뀜)
    onTap: () {},
    onLongPress: () {},
    hoverColor: Colors.red, // (Web 실행) - 마우스 포인터가 ListTile 위로 올라갔을 때 ListTile 의 Color 변경
    horizontalTitleGap: 10, // trailing 과 title , subtitle 간격 조절
    minVerticalPadding: 10, // title , subtitle 의 top 과 bottom 의 최소 padding 값
    minLeadingWidth: 40, // leading 의 최소 Width 값
    contentPadding: EdgeInsets.fromLTRB(15, 15, 15, 15), // ListTile 의 외곽 padding 값
  ),
최근 글
Dev_Whale의 Flutter 블로그
추천하는 글
Dev_Whale의 Flutter 블로그
💬 댓글 개
이모티콘창 닫기
울음
안녕
감사해요
당황
피폐

이모티콘을 클릭하면 댓글창에 입력됩니다.