dart - 如何仅将填充应用于 Flutter 中 TextField 中的文本?
问题描述
没有填充我得到这个结果:
像这样
Padding(padding: EdgeInsets.all(20.0), child: TextField())
我得到以下结果:
可能有点难看,但你只需要看看边缘的红色徽章就能明白我的意思。
我只想用我的填充移动文本,但实际上整个TextField
都应用了填充,即下划线随着填充移动,但我希望下划线仍然穿过整个视图,只有文本内部TextField
受填充影响。
解决方案
将填充应用于TextField
. 您可以申请
TextField 的装饰属性中的 ItemDecoration 的 contentPadding 属性。
像这样:
TextField(
textAlign: TextAlign.left,
decoration: InputDecoration(
hintText: 'Enter Something',
contentPadding: EdgeInsets.all(20.0),
),
)
推荐阅读
- javascript - 使用节点缓存更新缓存数据
- spring - 如何连接Spring和Oracle db(oracle cloud)19c
- spring-boot - springboot服务的Junit5测试用例如何调用repository的真实方法
- javascript - 编辑嵌套 iframe react-native-webview 中元素的属性
- cmsis - STM32F10x Flash 大小不匹配
- php-7.2 - Laravel 临时空白页对某些用户没有错误
- javascript - JS Electron 解码 base 64 Uint8array
- c# - 新的 WIn UI 项目崩溃
- javascript - 使用lookbehind忽略两个匹配项之间的字符串,但无论如何都要捕获它
- java - 如何使用 SSL/SSH 工作示例连接 SecureAS400