【问题标题】:TextFormField in flutter颤动中的TextFormField
【发布时间】:2020-10-11 02:19:12
【问题描述】:

我有问题。我创建了一个 TextFormField。当文本长度如此之长时,我希望 textField 将显示为下图。帮我。谢谢。

这是代码:

TextFormField(
            controller: nameController,
            enabled: false,
            textInputAction: TextInputAction.next,
            keyboardType: TextInputType.emailAddress,
            style: TextUtil.regularArial.copyWith(
              fontSize: ScreenUtil.getInstance().setSp(14),
              color: ColorUtil.grey8E8E8E,
            ),
            decoration: InputDecoration(
              fillColor: Colors.white,
              filled: true,
              isDense: true,
              enabledBorder: OutlineInputBorder(
                borderRadius: BorderRadius.all(Radius.circular(6)),
                borderSide: BorderSide(color: Colors.white, width: 1),
              ),
              hintText: "Email",
              hintStyle: TextUtil.regularArial.copyWith(
                fontSize: ScreenUtil.getInstance().setSp(14),
                color: ColorUtil.grey7A7A7A,
              ),
            ),
            validator: (value){
             
            },
          ),

【问题讨论】:

  • 到目前为止您尝试过什么?请分享代码
  • 您可以在带有溢出的文本中实现此目的:省略号属性。您也可以在下面尝试@youOne 的回答。看看这个:stackoverflow.com/questions/44579918/…
  • 我在帖子中更新了我的代码。

标签: flutter flutter-layout


【解决方案1】:

尝试添加 maxLines: null

TextFormField(maxLines: null)

如果maxLines属性为null,则不限制行数,并启用换行。

【讨论】:

  • 我使用了 maxLines: null 但它只扩展高度 TextField
  • 我只想在一行上显示 TextFormField
  • 很抱歉,我不知道答案,您为什么要这样做,但有人输入了他们的电子邮件地址,但他们看不到电子邮件的其余部分。但是,如果您尝试使用 Text 进行操作,您可以尝试添加 TextOverflow.ellipsis Text("Very Long Text", overflow: TextOverflow.ellipsis) 它会像魅力一样工作
  • 没关系,谢谢你的帮助。
猜你喜欢
  • 2019-09-26
  • 2021-06-28
  • 1970-01-01
  • 2020-12-02
  • 2022-01-12
  • 2021-11-02
  • 1970-01-01
  • 2021-08-17
  • 2020-06-22
相关资源
最近更新 更多