颤音:对齐中心一个特定的孩子窗口小部件
我是Flutter中的新手,我正在尝试编码UI Instagram克隆,如何使用row()
parent of like the Center将轮播指示器对齐中心 this
Stack(
alignment: Alignment.center,
children:[
buildIndicator(),
//Icon section
Row(
children:[
buildLeftIcons(),
buildRightIcon(),
],
),
],
),
结果我得到了: ![最终结果] [this]
I'm a newbie in flutter and I'm trying to code a UI Instagram clone, How can I align a carousel indicator to the center with a Row()
parent like
this
Stack(
alignment: Alignment.center,
children:[
buildIndicator(),
//Icon section
Row(
children:[
buildLeftIcons(),
buildRightIcon(),
],
),
],
),
Result I got:
![final result][this]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嘿,您可以在行儿童中使用图标和点之间的垫片()。 额外宽度 -
这是
展开
widget and row的另一个示例。
垫片窗口小部件自动在下面的 href =“ https://api.flutter.dev/flutter/widgets/spacer-class.html” rel =“ nofollow noreferrer”> spacer 和
展开
Hey you can use Spacer() between icons and dot in row children . Spacer widget auto take extra width like below -
Here is another example with
Expanded
widget and row, Expanded will automatically take rest of width other then icons// UI with left and right icons
For you reference - Spacer and
Expanded
在该行中,您可以在范围内给出一个
size box(width:)
,以将特定的小部件推动一定距离。In the row, you can give a
SizedBox(width: )
in the range to push a specific widget a certain distance.这样做会以某种方式复杂,但是我有两个建议:
row()
'smainaxisalignment.start
然后在第一个小部件和指示器之间添加一个所需的小部件,给出空间,例如sizedbox(width:80.0)
column()
将两个小部件分开。我更喜欢这个,因为我只会在列中添加轮播指示器作为第一个项目,然后将其包装在center()
widget中,那么列中的第二个小部件将是您所需的窗口小部件(fely,messages,messages,消息和评论图标)It would somehow complex to do that but I have two suggestions:
Row()
'sMainAxisAlignment.start
then add a desired Widget in between the first widgets and the indicators to give space say like aSizedBox(width:80.0)
Column()
. I prefer this since I would just add the carousel indicator as first item in the column then wrap it in aCenter()
widget, then the second widget in the column would be your desired widgets(favourite, message and comments icons)