我可以基于另一个小部件定位一个小部件吗?

Tiled Layout个 没有

Flutter 交错网格视图库

推荐答案

没有类似于ConstraintLayoutWidget,但是您可以使用不同的小部件来实现您想要的,如下例所示:

  class Testing2 extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Container(
        color: Colors.red,
        child: Row(
          children: <Widget>[
            Flexible(
              child: Column(
                children: <Widget>[
                  Flexible(
                    flex: 1,
                    child: Container(
                      color: Colors.deepOrange,
                    ),
                  ),
                  Flexible(
                    flex: 2,
                    child: Container(
                      color: Colors.lightBlue,
                    ),
                  ),
                ],
              ),
            ),
            Flexible(
              child: Column(
                children: <Widget>[
                  Flexible(
                      flex: 3,
                      child: Container(
                        color: Colors.orange,
                      )),
                  Flexible(
                    flex: 1,
                    child: Row(
                      children: <Widget>[
                        Flexible(
                            flex: 2,
                            child: Container(
                              color: Colors.blue,
                            )),
                        Flexible(child: Container(color: Colors.green))
                      ],
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      );
    }

Result

你也可以看看这个链接来了解布局小部件:https://flutter.io/widgets/layout/

Flutter相关问答推荐

在Row中包裹小部件

如何增加容器高度?

在Flutter中创建具有固定行的压缩水平列表

Flutter:如何从Bottom Navigator中删除此内容

手势捕获的异常:类型';Double';不是类型转换中类型';Double';的子类型

如何在应用程序启动时解析和加载JSON文件?

更改BottomNavigationBar onTap?的大小

使用Future函数的容器中未显示图像,但在使用图像小工具时显示

上传的图像不能在FireBase中预览.S档案类型为空白,摆动

Flutter类调用另一个类中的另一个方法失败

尽管 onCollision 处理了我的角色还是从平台上掉了下来

Flutter 使用扩展的 TextField 定位小部件

Flutter 3.10 - 'window' 已弃用,不应使用

Flutter ImagePicker - 在 onPressed 中异步获取图像显示 lint 警告

是否可以在 flutter 应用程序中使用 jetpack compose?

如何解决需要一个标识符,但得到的是:.try 在:之前插入一个标识符.dart 错误

这是使用导航功能处理从一页到另一页的移动的最佳方式

有没有办法为文本中的下划线创建自定义样式?

容器在发布模式下显示灰色框(抖动)

Flutter 平台通道将多数据传递给 windows 功能