0

我是新手,现在我正在尝试做类似的事情: img 1
textformfield 与复选框内联对齐,并且复选框在角落处缩小,但我能做的最大值是: img 2
在复选框填充一半屏幕的情况下,我尝试以多种方式扩展 textformfield,例如 sizedbox、flex 和 expand,但是没有一个使复选框缩小到角落并且 textformfield 扩展,行总是拆分在中间。实际的行代码如下所示:

Row(
    children: [
              Expanded(
                  child: TextFormField(
                    style: TextStyle(
                        fontSize: 20
                    ),
                    decoration: InputDecoration(
                      hintText: "Senha",

                    ),
                    autocorrect: false,
                    obscureText: true,
                  ),
                ),
              Flexible(

                  child: SizedBox(
                    width: 10,
                    child: Checkbox(value: true, onChanged: (value){}),
                )
              )
            ],
          ),

我有什么办法可以做到这一点吗?我必须使用容器或类似的东西吗?
任何帮助,将不胜感激。

4

2 回答 2

0

您可以使用CheckboxListTile 类

CheckboxListTile(
      title: const Text('Title'),
      value: value,
      onChanged: (value) {
        print(value);
      },
    );

让我知道它是否适合你。

于 2021-03-16T12:46:05.570 回答
0

我已经设法使用 flex 属性来做到这一点,如以下代码所示:

          Row(
            children: [
              Expanded(
                flex: 11,
                child: TextFormField(
                  style: TextStyle(
                      fontSize: 20
                  ),
                  decoration: InputDecoration(
                    hintText: "Usuario",

                  ),
                  autocorrect: false,
                  obscureText: true,
                ),
              ),
              Flexible(

                  child: SizedBox(
                    width: 10,
                    child: CheckboxListTile(
                      value: true,
                      onChanged: (value) {
                      },
                    ),
                  )
              )
            ],
          ),
于 2021-03-16T13:41:50.790 回答