我有一个Row孩子们是Expanded小部件的地方。我的目标是如果没有足够的空间容纳所有孩子,则将其包装起来Row(就像 一样)。Wrap
我已经尝试替换Row为Wrap:
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)