小编Raf*_*fal的帖子

Stack inside Stack in flutter

我想在颤动中将 Stack 放在 Stack 里面,如果我改变内部 Stack 的定位小部件的位置,它就不起作用。

作品:

Stack(
    children: [
      Positioned(
        top: 150.0,
        child: Text("Text#1"),
      ),
      Positioned(
        top: 100.0,
        child: Stack(
          children: [
            Positioned(
              child: Text("Text#2"),
            )
          ],
        ),
      )
    ],
  )
Run Code Online (Sandbox Code Playgroud)

如果我在内部堆栈的定位内添加“top:200.0”,内部堆栈消失并且颤动抛出错误

Stack(
    children: [
      Positioned(
        top: 150.0,
        child: Text("Text#1"),
      ),
      Positioned(
        top: 100.0,
        child: Stack(
          children: [
            Positioned(
              top:200.0,
              child: Text("Text#2"),
            )
          ],
        ),
      )
    ],
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

8
推荐指数
1
解决办法
3434
查看次数

标签 统计

dart ×1

flutter ×1

flutter-layout ×1