【问题标题】:Show hint text On Text("I'm text" , hint : " my hint " ) flutter在文本上显示提示文本(“我是文本”,提示:“我的提示”)颤动
【发布时间】:2020-06-15 13:40:48
【问题描述】:

我想像安卓一样在 Text() 上显示提示文本。但是我在flutter中没有找到任何与TextView相关的提示键。

像这样。

 Text("", hint : "Choose State")

【问题讨论】:

  • 你用它来输入?
  • 使用 Textfield 而不是 Text 作为 hintText
  • 我只是使用文本单击并选择要在相同文本上设置的值。但在没有选择之前,我只想在那个文本上提示一下。

标签: android ios flutter dart


【解决方案1】:

您需要使用textfield,它具有InputDecoration 类型的属性decoration,并且将包含hintText 属性:

TextField(
  decoration: InputDecoration(
    border: InputBorder.none,
    hintText: 'Choose State'
  ),
);

https://flutter.dev/docs/cookbook/forms/text-input

【讨论】:

  • 我只是使用文本单击并选择要在相同文本上设置的值。但在没有选择之前,我只想在那个文本上提示一下
【解决方案2】:

我自己做的。

var selectedValue = null;
Text(selectedValue ?? "Choose Country")

如果selectedValuenull,那么我将显示可选值,即。 "Choose Country"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-17
    • 2020-01-31
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    相关资源
    最近更新 更多