【问题标题】:How to allign row to fixed place如何将行对齐到固定位置
【发布时间】:2022-01-25 11:56:36
【问题描述】:

我有这个List view.builder

child: ListView.builder(
              itemCount: coins.length,
              itemBuilder: (BuildContext context, int index) {
                return ListTile(
                  leading: iconsList[index],
                  title: Wrap(children: [
                    Row(children: [
                      Text(
                        coins[index],
                        style: const TextStyle(color: Colors.white),
                      ),
                      Text(
                        value[index],
                        style: TextStyle(color: Colors.white),
                      ),
                    ]),
                  ]),
                  subtitle: Align(
                    alignment: Alignment.bottomRight,
                    child: Text(
                      value[index],
                      style: TextStyle(color: Colors.white),
                    ),
                  ),
                );
              }),

在手机屏幕上显示是这样的:

我想将欧元金额放在硬币零钱上方的右上方,如下所示:

我应该如何将金额以欧元为单位,以便它看起来像我展示的示例图像?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    只需在Row 下使用mainAxisAlignment: MainAxisAlignment.spaceBetweencrossAxisAlignment: CrossAxisAlignment.center,,无需使用字幕,只需将右侧元素与Column 绑定并根据需要更改文本样式

    ListTile(
                   leading: Icon(Icons.add),
                  title: Wrap(children: [
                    Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Text(
                            "coins[index]1",
                            style: const TextStyle(color: Colors.white),
                          ),
                          Column(
                            children: [
                              Text(
                                "value[index]2",
                                style: TextStyle(color: Colors.white),
                              ),
                              Text(
                                "value[index]3",
                                style: TextStyle(color: Colors.white),
                              ),
                            ],
                          )
    
                        ]),
                  ]),
    
                )
    

    输出:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-12
      • 2015-10-21
      • 1970-01-01
      • 2012-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多