我是使用Flutter
的新手,我需要将小部件放在一行上,但这是行不通的。请帮助任何人。
class HelloWorld extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 50,
width: 50,
color: Colors.red,
Container(
height: 50,
width: 50,
color: Colors.blue,
);
}
}
答案 0 :(得分:2)
您可以使用image_to_world_plane (FrontFaceReduced, FrontFaceReducedWorld, CamParam, PoseNewOrigin, 600, 600, 'mm', 'bilinear')
小部件来水平对齐小部件。
要详细了解Flutter中的小部件,请查看以下链接:
检查以下代码:
image_to_world_plane (Image, FrontFaceReducedWorld, CamParam, PoseNewOrigin, 600, 600, 'mm', 'bilinear')
答案 1 :(得分:2)
Container(
height: 50,
width: 50,
color: Colors.red,
Container(
height: 50,
width: 50,
color: Colors.blue,
);
您正在执行的实现方式有误,并且代码无法正常工作,因为您正在向容器内添加容器,但是这可能会给您带来错误,因为没有为内部容器指定任何子代作为父代。 您可以只一行并在其中添加两个容器
Row(
children: <Widget>[
Container(),// you can add the paramenters for both
Container(),
],),
答案 2 :(得分:1)
使用“行小部件”将它们彼此对齐。
MY_CONSTANT = False
if MY_CONSTANT:
print("Special case")
答案 3 :(得分:1)
有两种方法可以做到
1。使用自动换行小工具
Wrap(children: <Widget>[
Container(
height: 50,
width: 50,
color: Colors.red,
),
Container(
height: 50,
width: 50,
color: Colors.blue,
),
])),
2。使用行小部件
Row(
children: <Widget>[
Container(
height: 50,
width: 50,
color: Colors.red,
),
Container(
height: 50,
width: 50,
color: Colors.blue,
),
],
),