首页 > 解决方案 > 我们如何在flutter中创建一个带有长标签的复选框?

问题描述

在此处输入图像描述 我正在尝试实现这样的目标。我是 Flutter 的新手。

我努力了

 Wrap(
//                      alignment: WrapAlignment.center,
                      crossAxisAlignment: WrapCrossAlignment.center,
                      direction: Axis.horizontal,
                      children: <Widget>[
                        Checkbox(value: false, onChanged: null),
                        RichText(
                          overflow: TextOverflow.visible,
                          textAlign: TextAlign.left,
                          text: TextSpan(
                              text: 'By continuing you agree to our ',
                              style: TextStyle(
                                  color: Colors.grey,
                                  fontWeight: FontWeight.normal,
                                  fontSize: 14),
                              children: [
                                TextSpan(
                                  text: 'Terms of Service, Privacy Policy,',
                                  style: TextStyle(
                                      color: Theme.of(context).primaryColor,
                                      fontWeight: FontWeight.w600,
                                      fontSize: 14),
                                ),
                                TextSpan(
                                  text: 'and our ',
                                  style: TextStyle(
                                      color: Colors.grey,
                                      fontWeight: FontWeight.w600,
                                      fontSize: 14),
                                ),
                                TextSpan(
                                  text: 'Notification Settings.',
                                  style: TextStyle(
                                      color: Theme.of(context).primaryColor,
                                      fontWeight: FontWeight.w600,
                                      fontSize: 14),
                                ),
                              ]),
                        ),
                      ],
                    ),

这就是我得到的2

3这是我尝试过的代码,但我越来越喜欢这样了。是否有任何其他方法可以将文本和复选框水平对齐,并将其余文本包裹起来。

标签: fluttercheckbox

解决方案


尝试使用CheckboxListTile,它内容 标题副标题属性


推荐阅读