首页 > 解决方案 > 为什么导入的小部件未显示在主屏幕颤动中

问题描述

我有一个主屏幕,我想导入另一个包含 3 个按钮的小部件。但是,小部件未显示在主屏幕中。

主文件中的代码:

          Padding(
              padding: EdgeInsets.only(left: 40.0),
              child: Row(
                children: <Widget>[
                  Text('Your',
                      style: TextStyle(color: Colors.white, fontSize: 25.0)),
                  SizedBox(
                    width: 10.0,
                  ),
                  Text('Invoice',
                      style: TextStyle(
                          color: Colors.white,
                          fontWeight: FontWeight.bold,
                          fontSize: 25.0))
                ],
              )),
          SizedBox(height: 40.0),
          Container(
              height: MediaQuery.of(context).size.height - 185.0,
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius:
                      BorderRadius.only(topLeft: Radius.circular(75.0))),
              child: ListView(
                  primary: false,
                  padding: EdgeInsets.only(left: 25.0, right: 20.0),
                  children: <Widget>[
                    Padding(
                        padding: EdgeInsets.only(top: 45.0),
                        child: Container(
                            height: MediaQuery.of(context).size.height - 300.0,
                            child: ListView(
                              children: [
                                buildInvoice(
                                    'Rent one month', 'July rent', '800€')
                              ],
                            )))
                  ])),
          Expanded(
            child: ButtonsDetailInvoice(),
          ),
        ],
      ),
    );
  }

按钮小部件中的代码:

    return Container(
      height: 450.0,
      // margin: const EdgeInsets.all(20.0),
      child: Row(
        children: [
          RaisedButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(18.0),
                side: BorderSide(color: colorBlau)),
            onPressed: () {},
            color: colorBlau,
            textColor: Colors.white,
            child: Row(
              children: <Widget>[
                Icon(Icons.file_download),
                Text('Download', style: TextStyle(fontSize: 15.0))
              ],
            ),
          ),
          RaisedButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(18.0),
                side: BorderSide(color: colorMint)),
            onPressed: () {},
            color: colorMint,
            textColor: Colors.white,
            child: Row(
              children: <Widget>[
                Icon(Icons.share),
                Text('Share', style: TextStyle(fontSize: 15.0))
              ],
            ),
          ),
          RaisedButton(
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(18.0),
                side: BorderSide(color: colorRed)),
            onPressed: () {},
            color: colorRed,
            textColor: Colors.white,
            child: Text('Report a Problem', style: TextStyle(fontSize: 15.0)),
          ),
        ],
      ),
    );
  }
}

我想看看主文件底部的按钮。我导入了它们,但它们没有显示。如果有人可以帮助查看错误,我将不胜感激。

标签: flutter

解决方案


在主文件中使用 Stack 小部件。


推荐阅读