【问题标题】:how to code int text at the bottom of rightside in checkboxlisttile with gridview如何使用gridview在checkboxlisttile的右侧底部编码int文本
【发布时间】:2020-12-20 03:13:05
【问题描述】:

我有一个关于 checkboxListTile 与 gridview 对齐的问题。

如何使用 gridview 在 checkboxListTile 的左侧底部编写 int 文本。

也许我认为那是“次要的”,但我不确定..

这是我的代码

return GridView.count(
                primary: false,
                crossAxisCount: 2,
                padding: const EdgeInsets.all(20),
                crossAxisSpacing: 10,
                mainAxisSpacing: 10,
                children: workoutList
                                .map(
                            (workout) => Material(
                              color: Colors.teal[400],
                              child: CheckboxListTile(
                                  title:
                                  Text(
                                    workout.title,
                                    style: TextStyle(fontSize: 14),
                                  ),
                                  value: workout.isDone,
                                  onChanged: (bool value) {
                                  workout.isDone = !workout.isDone;
                                  model.reload();
                                  },
                              ),
                            ),

                            )
                                .toList(),
                );

【问题讨论】:

    标签: flutter flutter-layout checkboxlist


    【解决方案1】:

    我将您的代码编辑为如下所示:

    return GridView.count(
                    primary: false,
                    crossAxisCount: 2,
                    padding: const EdgeInsets.all(20),
                    crossAxisSpacing: 10,
                    mainAxisSpacing: 10,
                    children: workoutList
                                    .map(
                                (workout) => Material(
                                  color: Colors.teal[400],
                                  child: Column(
                                     children: <Widget>[
                                         CheckboxListTile(
                                      title:
                                      Text(
                                        workout.title,
                                        style: TextStyle(fontSize: 14),
                                      ),
                                      value: workout.isDone,
                                      onChanged: (bool value) {
                                      workout.isDone = !workout.isDone;
                                      model.reload();
                                      },
                                  ),
                                        Align(
                                        alignment: Alignment.bottomRight,
                                         child: Text("count"),
                                           ),
                                      ],
                                  ),
                                ),
    
                                )
                                    .toList(),
                    );
    

    通过使用 Align 小部件,我们可以将 Text 小部件与右下角对齐

    【讨论】:

    • 我按照您的建议进行编码,但 align 不是右下角...
    • 对不起,右侧而不是左侧,在您更改后,它是否提供了您需要的东西?
    猜你喜欢
    • 1970-01-01
    • 2021-01-30
    • 2023-03-31
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-10
    相关资源
    最近更新 更多