ListView.builder с динамической c высотой элементов - PullRequest
0 голосов
/ 01 февраля 2020

У меня есть ListView с динамическим c содержимым, где я хотел бы, чтобы каждый элемент имел динамическую c высоту в зависимости от их содержимого, но если я не установил фиксированную высоту для каждого элемента, я получаю ошибку

пакет: flutter / src / render / sliver_multi_box_adaptor.dart ': Неудачное утверждение: строка 549 ​​поз. 12:' child.hasSize ': не соответствует действительности.

Вот мой полный макет для ListView itemBuilder:

return Container(
  key: _key,
  // If I set height: 500 here it works
  child: InkWell(
    onTap: () => _cardTap(_key, context, house),
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(16.0),
        ),
        semanticContainer: true,
        clipBehavior: Clip.antiAliasWithSaveLayer,
        elevation: 4,
        child: Container(
      color: Colors.white,
      child: Stack(
        fit: StackFit.expand,
        children: <Widget>[
          ImageHelper.getHouseCategoryImage(widget.house.houseCategory),
          Padding(
            padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
            child: Align(
              alignment: Alignment.topLeft,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          widget.house.addressStreet,
                          style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: Colors.white),
                        ),
                      ),
                      Align(
                        alignment: Alignment.centerRight,
                        child: IconButton(
                          icon: Image.asset(widget.isFullscreen ? 'assets/images/button_collapse.png' : 'assets/images/button_expand.png'),
                        ),
                      )
                    ],
                  ),
                  SizedBox(
                    height: 56,
                  ),
                  Row(
                    children: <Widget>[
                      Expanded(
                        child: Text(
                          'Boligværdi',
                          style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white),
                        ),
                      ),
                      Align(
                        alignment: Alignment.centerRight,
                        child: Text(
                          '4.233.123',
                          style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white),
                        ),
                      )
                    ],
                  ),
                  SizedBox(
                    height: 32,
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                        borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                          borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                          borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                          borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                          borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: Container(
                      height: 60,
                      decoration: BoxDecoration(
                          color: Color(0xFFFFFFFF),
                          borderRadius: BorderRadius.circular(10.0)
                      ),
                    ),
                  )
                ],
              ),
            ),
          )
        ],
      ),
    )
      )
    )
);

Как получить элементы (контейнер, карточку или столбец, являющийся проблемой ...), чтобы получить высоту, необходимую для отображения содержимого?

Спасибо
Сёрен

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...