@Davidaa_WoW

Почему виджет Expanded выдаёт ошибку?

Есть длинное название. Требуется переносить его на новую строку. Как я понимаю во Flutter это можно сделать только при помощи оборачивания текста в Expanded, или Flexible. Оборачиваю, начинает ругаться компилятор, выдавая предупреждение:
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.

The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type ParentData.

Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Semantics widget.

The ownership chain for the RenderObject that received the incompatible parent data was:
  ConstrainedBox ← Container ← Expanded ← LoadingContainer ← SystemScreen ← Semantics ← Builder ← RepaintBoundary-[GlobalKey#de15f] ← IgnorePointer ← AnimatedBuilder ← ⋯


При этом у меня вроде все условия соблюдены. Expanded обёрнут в Row(). На что он ругается-то, понять не могу?

Вот моё дерево виджетов:
Scaffold(
            backgroundColor: Colors.white,
            body: Stack(
                    children: [
                      Column(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Padding(
                            padding: const EdgeInsets.symmetric(horizontal: 20),
                            child: Center(
                                child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                  Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.center,
                                      children: [
                                        Expanded(child:
                                          Text(
                                            'Длиииииииииииииииииииииииинный текст',
                                            style: Theme.of(context)
                                                .textTheme
                                                .labelLarge,
                                            textAlign: TextAlign.justify,
                                          ),
                                        ),
                                      ]
                                  ),
  • Вопрос задан
  • 43 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Neonoviiwolf
Flutter developer
https://habr.com/ru/articles/500210/

потому что row/column/stack не ограничивают виджет по размеру
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы