[Flutter] ExpansionPanel - 눌러서 확장

박철영·2021년 7월 28일
0
post-thumbnail
ExpansionPanelList(
  animationDuration: Duration(milliseconds: 500),
  children: [
    ExpansionPanel(
      headerBuilder: (context, isExpanded) {
        return Row(
          children: [
            Container(
              width: 100,
              height: 100,
              child: Image.network(
                  "https://musicmeta-phinf.pstatic.net/album/005/211/5211473.jpg"),
            ),
            SizedBox(width: 20,),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  "IU 5th Album 'LILAC'",
                  style: TextStyle(
                      fontWeight: FontWeight.bold,
                    fontSize: 20
                  ),
                ),
                Text(
                    "아이유(IU)",
                  style: TextStyle(
                      color: Colors.grey,
                  ),
                ),
                Text(
                  "2021.3.25 댄스",
                  style: TextStyle(
                    color: Colors.grey,
                  ),
                )
              ],
            )
          ],
        );
      },
      body:Column(
        children: [
          for (var i = 0; i < _item.length; i++)
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
              child: Row(
                children: [
                  Container(
                    width: 20,
                    alignment: Alignment.center,
                    child: Text("${i+1}"),
                  ),
                  SizedBox(width: 20,),
                  Expanded(child: Text(_item[i].title)),
                  Text(_item[i].singer)
                ],
              ),
            )
        ],
      ),
      isExpanded: _expanded,
      canTapOnHeader: true,
    ),
  ],
  expandedHeaderPadding: EdgeInsets.all(0),
  expansionCallback: (panelIndex, isExpanded) {
    _expanded = !_expanded;
    setState(() {

    });
  },
),

3개의 댓글

comment-user-thumbnail
2021년 9월 30일

_item[i].title <= 이 부분에 관한 질문입니다.

List<Map<String, int>> 형식으로 만들었는데 꺼내오질 못합니다...

***The getter 'title' isn't defined for the type 'Map<String, int>'.
Try importing the library that defines 'title', correcting the name to the name of an existing getter, or defining a getter or field named 'title'.

라고 오류가 나오는데 혹시 어떻게 하셨나요?

2개의 답글