Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想制作一个文本表单字段,以便当我按下文本表单字段时字段的颜色会发生变化,当文本表单字段为空时更改颜色并在内容存在时更改颜色。与文本表单域的边框相同。我怎样才能做到这一点?如果可能的话,请给我一个例子。
您可以通过调用 setState 来使用 TextFormField 的 onTap 参数来更新颜色,在此之前将表单字段颜色和边框配置分配给变量,并在点击 TextFormField 后使用 set State 更新颜色和配置