繁体   English   中英

如何将小部件放置在连续包含的卡内?

[英]How do I position widgets inside a card contained in a row?

目前,我正在尝试创建卡片模板以插入列表视图。 我希望带有图标按钮的列位于最右边。 我似乎找不到一种方法可以说包含图标按钮的列需要向右刷新。

new Expanded(
            child: new ListView(
              shrinkWrap: true,
              padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
              children: <Widget>[
                new Card(
                  child: new Row(
                    children: <Widget>[
                      new Padding(
                        padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0),
                      ),
                      new Image(
                        //image: new AssetImage("assets/ic_access_alarm_red_24dp.png"),
                        image: new AssetImage("assets/pastDue.png"),
                        height: 50.0,
                        width: 50.0,
                      ),
                      new Padding(
                        padding: const EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0),
                      ),
                      new Column(
                        children: <Widget>[
                          new Text("This is the title"),
                          new Text("This is the Description"),
                          new Text("This is the date"),
                        ],
                      ),
                      new Column(
                        children: <Widget>[
                          new IconButton(
                            icon: new Icon(Icons.note_add),
                            onPressed: () {
                              select("AddCalibration");
                            }
                          ),
                          new IconButton(
                            icon: new Icon(Icons.edit),
                            onPressed: () {
                              select("EditInstrument");
                            }
                          )
                        ],
                      )
                    ],
                  )
                ),

                const Text("I am"),
                const Text("A ListView"),
              ],
            )
          )

这是当前外观的捕获。

谢谢你,vbandrade!

这肯定解决了我的问题。

new Expanded(
              child: new ListView(
            shrinkWrap: true,
            padding: const EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0),
            children: <Widget>[
              new Card(
                child: new ListTile(
                  leading: new Image(
                    image: new AssetImage("assets/pastDue.png"),
                    height: 50.0,
                    width: 50.0,
                  ),
                  title: new Column(
                    children: <Widget>[
                      new Text("This is the title"),
                      new Text("This is the Description"),
                      new Text("This is the date"),
                    ],
                  ),
                  trailing: new Column(
                    children: <Widget>[
                      new IconButton(
                          icon: new Icon(Icons.note_add),
                          onPressed: () {
                            select("AddCalibration");
                          }),
                      new IconButton(
                          icon: new Icon(Icons.edit),
                          onPressed: () {
                            select("EditInstrument");
                          })
                    ],
                  ),
                ),
              ),
              const Text("I am"),
              const Text("A ListView"),
            ],
          ))

这是最终结果。

使用扩展小部件将图标向右推

new Expanded(child: new Container())

所以在您的示例中:new Column(

 children: <Widget>[
 new Text("This is the title"),
 new Text("This is the Description"),
 new Text("This is the date"),],
 ),
 new Expanded(child: new Container()),
 new Column(
 children: <Widget>[
 new IconButton(
 icon: new Icon(Icons.note_add),
 onPressed: () {}),

暂无
暂无

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

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