Flutter:如何制作带有 HintText 但没有下划线的 TextField? [英] Flutter: how to make a TextField with HintText but no Underline?

查看:41
本文介绍了Flutter:如何制作带有 HintText 但没有下划线的 TextField?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想要做的:

在文本字段的 Flutter 文档中 (https://flutter.io/text-input/) 它说您可以通过将 null 传递给装饰来删除下划线.但是,这也摆脱了提示文本.

In the Flutter docs for Text Fields (https://flutter.io/text-input/) it says you can remove the underline by passing null to the decoration. However, that also gets rid of the hint text.

无论文本字段是否聚焦,我都不想要任何下划线.

I do not want any underline whether the text field is focused or not.

更新:更新了已接受的答案,以反映截至 2020 年 4 月 Flutter SDK 的变化.

UPDATE: updated accepted answer to reflect changes in Flutter SDK as of April 2020.

推荐答案

新的 flutter sdk,因为在集成了 web 和桌面支持之后,你需要像这样单独指定

new flutter sdk since after integration of web and desktop support you need to specify individually like this

TextFormField(
    cursorColor: Colors.black,
    keyboardType: inputType,
    decoration: new InputDecoration(
        border: InputBorder.none,
        focusedBorder: InputBorder.none,
        enabledBorder: InputBorder.none,
        errorBorder: InputBorder.none,
        disabledBorder: InputBorder.none,
        contentPadding:
            EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
        hintText: "Hint here"),
  )

这篇关于Flutter:如何制作带有 HintText 但没有下划线的 TextField?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆