【问题标题】:TextField/TextFormField keeps displaying the beginning of input string when the input string doesn't fit in the text field entirely当输入字符串不完全适合文本字段时,TextField/TextFormField 继续显示输入字符串的开头
【发布时间】:2022-01-10 16:23:50
【问题描述】:

当输入不再适合TextField 时,我想显示输入字符串的结尾。

从上面的屏幕记录中可以看出,一旦输入文本变得足够大以至于无法放入TextField,视图就会卡在字段的开头。 我想以某种方式继续显示文本的结尾(随着输入变大)并可以滚动到开头(与现在完全相反)。这可能吗?

这是我的代码:

Consumer(
  builder: (context, ref, _) {
    current.text = ref.watch(historyProvider.state).state;
    return Align(
      alignment: Alignment.topRight,
      child: TextField(
        toolbarOptions: const ToolbarOptions(
          copy: true,
          selectAll: true,
        ),
        decoration: const InputDecoration(
          border: InputBorder.none,
        ),
        keyboardType: TextInputType.none,
        controller: current,
        showCursor: false,
        textAlign: TextAlign.end,
        cursorColor: Colors.transparent,
        style: const TextStyle(
            fontSize: 28, color: Color(0xFF7F7FA5)),
      ),
    );
  },
),

【问题讨论】:

    标签: flutter dart flutter-layout


    【解决方案1】:

    试试这个----

     SingleChildScrollView(
            scrollDirection: Axis.horizontal,
            child: ConstrainedBox(
              constraints: BoxConstraints.expand(width: 100),
              child: TextField(
                maxLines: 1,
                // controller and etc.
              ),
            ),
          )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-25
      • 1970-01-01
      • 1970-01-01
      • 2021-05-30
      • 1970-01-01
      • 2015-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多