相关疑难解决方法(0)

Flutter - 包裹行展开的小部件

我有一个Row孩子们是Expanded小部件的地方。我的目标是如果没有足够的空间容纳所有孩子,则将其包装起来Row(就像 一样)。Wrap

我已经尝试替换RowWrap

return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Wrap(
          children: [
            Expanded(
              child: element("Sun Glasses"),
            ),
          ],
        )
      ),
    );
Run Code Online (Sandbox Code Playgroud)

但这会导致错误:

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 WrapParentData.

Usually, this means that …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

5
推荐指数
1
解决办法
4395
查看次数

标签 统计

dart ×1

flutter ×1

flutter-layout ×1