繁体   English   中英

如何根据 Flutter Widget 中的 parends 设置宽度

[英]How to set width according to parends in Flutter Widget

材料(海拔:0,

      child:

        Container(
          margin: const EdgeInsets.only(
            bottom: 10
          ),
          child: Stack(

            children: <Widget>[
              Positioned(
                left: 30,
                child: Container(

                  padding: EdgeInsets.only(
                      left: 50
                  ),
                  height: 80,
                  color: Colors.black12,
                  child: Text("From : " + bills[index].fromDate.toString() + ""
                      "to : " + bills[index].toDate.toString()),
                ),
              ),
                  Container(
                        width: 80.0,
                        height: 80.0,
                        decoration: new BoxDecoration(
                          color: Colors.orange,
                          shape: BoxShape.circle,
                        ),
                ),
              Positioned(
                top: 20,
                left: 10,
                child: Text(bills[index].bill.toString() + bills[index].currency),
              ),


          ],

      ),
        ),
    );

在上面的代码中,下面的这个小部件是堆栈的成员,我无法根据父母设置宽度。 通常,我会在 flutter 中设置 match_parent 属性。 我应用 SizedBox.extend 解决方案。 该解决方案对我不起作用。
定位(左:30,子:容器(

                  padding: EdgeInsets.only(
                      left: 50
                  ),
                  height: 80,
                  color: Colors.black12,
                  child: Text("From : " + bills[index].fromDate.toString() + ""
                      "to : " + bills[index].toDate.toString()),
                ),
              ),

请帮帮我。 提前致谢。

你可以试试:

Positioned(
   left: 30,
   right: 0,
   child: Container(
      /* your widget */
   )
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM