简体   繁体   English

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

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

Material( elevation: 0,材料(海拔: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),
              ),


          ],

      ),
        ),
    );

In the above code, this widget below is a member of the stack and I could not set width according to the parents.在上面的代码中,下面的这个小部件是堆栈的成员,我无法根据父母设置宽度。 usually, I suffer setting match_parent attribute in a flutter.通常,我会在 flutter 中设置 match_parent 属性。 I apply SizedBox.extend solution.我应用 SizedBox.extend 解决方案。 the solution doesn't work for me.该解决方案对我不起作用。
Positioned( left: 30, child: Container(定位(左:30,子:容器(

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

Please help me out.请帮帮我。 thanks in advance.提前致谢。

You can try:你可以试试:

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

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

相关问题 如何设置 flutter 切换按钮小部件的宽度 - How to set width of the flutter togglebuttons widget 如何根据Flutter中的按钮单击来上下移动一个小部件? - How to move Up and Down one widget according to button click in Flutter? 如何根据 flutter 中的不同屏幕尺寸对齐堆栈内的小部件 - How to align widget inside stack according to different screen sizes in flutter 如何根据颤动中的屏幕更改文本大小和小部件大小? - How to change textsize and widget size according to screen in flutter? 如何根据android中的设备宽度设置edittext的宽度? - how to set width of edittext according to the device's width in android? 如何减小 Flutter 抽屉内开关小部件的宽度 - How do i decrease the width of a switch widget inside a drawer in Flutter 如何根据android中的文本内容动态设置按钮的宽度? - How to set dynamically the width of button according to its text content in android? 如何根据最小和最大列宽设置GridView中的列数? - How to set number of columns in GridView according to minimal and maximal column width? 如何根据视频的高度和宽度设置屏幕方向 - How to set screen orientation according to a video's height and width 如何根据另一个视图的位置设置视图宽度? - How to set view width according to another view's position?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM