小编Imt*_*pto的帖子

Flutter Container 在 Row 小部件内定位或对齐

我是颤振的新手。现在正在学习如何定位或对齐小部件。我的行小部件中有两个容器。我想在左上角设置我的第一个容器(红色容器),还想在右上角设置我的第二个容器(蓝色容器)。我怎样才能做到这一点?

这是代码示例:

class MyRow extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.teal,
        body: SafeArea(
          child: Row(
            children: <Widget>[
              Container(
                width: 100.0,
                height: 100.0,
                color: Colors.red,
              ),
              Container(
                width: 100.0,
                height: 100.0,
                color: Colors.blue,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

flutter flutter-container flutter-widget

2
推荐指数
1
解决办法
8678
查看次数