为什么当我将高度设置为double.infinity时,显示屏上显示错误?

时间:2019-10-02 03:01:35

标签: flutter flutter-layout flutter-test

我的代码如下

  get _pdfViewer{
    if(pathPDF != null) return Container(
      child: PdfViewer(
        filePath: pathPDF,
      ),
      color: Colors.red,
    );
    else return Container(height: 30,color: Colors.blueAccent,);
  }
Column(
        children: <Widget>[
          Flex(
            direction: Axis.horizontal,
            children: <Widget>[
              Expanded(
                flex: 7,
                child:  Container(
                  height: 500,
                  color: Colors.blueAccent,
                  child: _pdfViewer,
                ),
              ),
              Expanded(
                flex: 1,
                child:Container(
                  height:500,
                  color: Colors.green,
                )
              ),
            ],
          )
        ],
      );

代码中的高度是两倍,当我将高度设置为 double.infinity 时,其担心(错误)如下所示: image

我想最大化应用程序的屏幕。我该怎么办?

1 个答案:

答案 0 :(得分:0)

如果要使用double.infinity值,则该列必须在容器小部件中。

ex)

Container(
    child : Column(/*enter your code*/),
)