I have a dilemma that I can't seem to solve. I have an existing row in Flutter. Essentially what I want to accomplish is to have the first element(yellow) at the start of the row, and the second element(red) in the center of the element. I know Row has the mainAxisAlignment
, but I need a different alignment for each each element (i.e. both MainAxisAlignment.start
& MainAxisAlignment.center
). Thanks for any help!
我能够得出的最接近的结果是:
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
yellowElement,
Expanded(child: redElement),
],
);
但这并不是完全居中,而是在黄色占据其空间后剩余的可用空间中居中。
几周前我遇到了这个问题,我发现的唯一解决方案是Stack ...像这样