ListView внутри ExpansionTile не работает - PullRequest
0 голосов
/ 11 января 2019

просмотр списка не работает внутри ExpansionTile

Я пытался показать listview.builder внутри ExpansionTile, но он выдает некоторые исключения

Card(
       child: ExpansionTile(
           leading: Icon(
              Icons.stars,
              color: Colors.pinkAccent,
           ),
           title: Text('Reviews',
                  style: Theme.of(context).textTheme.title,
                          ),
                children: [
                    ListView.builder(
                        itemCount: 5,
                        itemBuilder: (_, i) {
                          return (Text('item $i'));
                     })
                   ],
             ),
     ),

я хочу достичь вот так https://imgur.com/a/0lubABC

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 8182): The following assertion was thrown during performResize():
I/flutter ( 8182): Vertical viewport was given unbounded height.
I/flutter ( 8182): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter ( 8182): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter ( 8182): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter ( 8182): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter ( 8182): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter ( 8182): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter ( 8182): the height of the viewport to the sum of the heights of its children.
I/flutter ( 8182): 

Ответы [ 2 ]

0 голосов
/ 27 июля 2019

Добавить как термоусадочную пленку, так и контроллер в ListView.builder

final ScrollController _scrollController = ScrollController();


    ListView.builder(
          controller: _scrollController,
           shrinkWrap: true,
    ...
0 голосов
/ 11 января 2019

Размер вашего ListView по вертикали неограничен, что делает невозможным его рендеринг. Установите shrinkWrap свойство ListView на true, чтобы обойти это.

...