当输入的文本宽度超过文本字段的宽度时,如何防止文本字段的混乱消失?

时间:2020-03-28 13:16:44

标签: flutter input overflow

我有一个文本字段,用于收集用户输入,但是当字符串的宽度超过文本字段的范围时,该文本就会消失。我如何通过随着文本长度的增加不断向左偏移文本来使文本溢出?

这是不需要的动作的演示,请注意在输入第9个键后该文本消失了。

enter image description here

这是我的代码段:

  Text.rich(
              TextSpan(
                  text: '',
                  children: <InlineSpan>[
                    WidgetSpan(
                        alignment: PlaceholderAlignment.baseline,
                        baseline: TextBaseline.alphabetic,
                        child: Container(
                          width: 130,
                          height: 30,
                          child: TextField(
                            controller: textFieldControllerList[i],
                            keyboardType: TextInputType.number,
                            style: TextStyle(
                                fontSize: 25.0,
                                color: textFieldColors[i],
                                decorationColor: textFieldColors[i]
                            ),
                            decoration: InputDecoration(
                                enabledBorder: OutlineInputBorder(
                                  borderSide: BorderSide(color: textFieldColors[i], width: 1.0),
                                ),
                                focusedBorder: OutlineInputBorder(
                                  borderSide: BorderSide(color: textFieldColors[i], width: 2.0),
                                ),
                                border: OutlineInputBorder(),
                                labelText: answer.label,
                              labelStyle: TextStyle(color: textFieldColors[i])
                            ),
                          ),
                        )
                    ),
                    TextSpan(text: answer.unitSymbol,style: TextStyle(fontSize: 25))
                  ])
          )

0 个答案:

没有答案