引发了另一个异常:BoxConstraints强制无限高

时间:2019-03-16 08:39:33

标签: dart flutter

我正在尝试构建此小部件,它会产生:

Another exception was thrown: BoxConstraints forces an infinite height.

这是我从超新星工作室获得的小部件,基于我在网上找到的草图。我知道生成器并没有真正考虑嵌套堆栈上的特殊约束,但是我无法解决此问题。问题是我认为某个堆栈具有无限的高度,但我不知道是哪一个。

这是我要构建的代码:

return new Container(
    height: 900.0,
    margin: EdgeInsets.only(top: 64),
    child: new Stack(
      fit: StackFit.expand,
      alignment: Alignment(0.0, 0.0),
      children: [
        new Positioned(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisSize: MainAxisSize.max,
            children: [
              Stack(
                children: [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: [
                      Container(
                        margin: EdgeInsets.only(left: 76),
                        child: Stack(
                          fit: StackFit.expand,
                          children: [
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.stretch,
                              children: [
                                Container(
                                  margin: EdgeInsets.symmetric(horizontal: 10),
                                  decoration: BoxDecoration(
                                    color: Color.fromARGB(255, 59, 72, 89),
                                    borderRadius: BorderRadius.all(Radius.circular(10)),
                                  ),
                                ),
                              ],
                            ),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.stretch,
                              children: [
                                Container(
                                  margin: EdgeInsets.only(left: 10, top: 120, right: 10),
                                  decoration: BoxDecoration(
                                    color: Color.fromARGB(255, 59, 72, 89),
                                    borderRadius: BorderRadius.all(Radius.circular(10)),
                                  ),
                                ),
                              ],
                            ),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.stretch,
                              children: [
                                Container(
                                  margin: EdgeInsets.only(top: 80),
                                  decoration: BoxDecoration(
                                    color: Color.fromARGB(255, 131, 146, 167),
                                    borderRadius: BorderRadius.all(Radius.circular(10)),
                                  ),
                                ),
                              ],
                            ),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.stretch,
                              children: [
                                Container(
                                  margin: EdgeInsets.only(top: 20),
                                  decoration: BoxDecoration(
                                    color: Color.fromARGB(255, 131, 146, 167),
                                    borderRadius: BorderRadius.all(Radius.circular(10)),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: [
                      Container(
                        margin: EdgeInsets.only(left: 66),
                        child: Image.asset(
                          "assets/photo-2.png",
                          fit: BoxFit.cover,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
              Container(

                margin: EdgeInsets.only(left: 134, top: 11),
                child: Text(
                  "${audioPlayer.isPlayingSong.title} \n${audioPlayer.isPlayingSong.artist}",
                  style: TextStyle(
                    color: Color.fromARGB(88, 255, 255, 0),
                    fontSize: 24,
                    letterSpacing: 0.82,
                    fontFamily: "",
                  ),
                  textAlign: TextAlign.center,
                ),
              ),
              Expanded(
                flex: 1,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.end,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    Container(

                      child: Image.asset(
                        "assets/wave.png",
                        fit: BoxFit.cover,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),

      ],
    ),
  );

0 个答案:

没有答案