InputDecoration.collapsed
是一个 InputDecoration
属性,用于控制 TextField
或 TextFormField
组件中输入框的外观。当该属性设置为 true
时,输入框的边框会被隐藏,但用户仍然可以在该组件中输入文本。
举个例子,假设你有一个 TextFormField
组件,要将它的边框隐藏起来,可以这样写:
TextFormField(
decoration: InputDecoration(
collapsed: true,
),
),
注意,当设置 InputDecoration.collapsed
为 true
时,TextField
或 TextFormField
组件中的其它属性(比如 hintText
)可能也会被隐藏,因此在使用该属性时需要谨慎。