flutter - 如何设置 InputDecoration 的 OutlineInputBorder 样式?
问题描述
我正在尝试设置TextFormField
. 我将它与OutlineInputBorder
. 默认情况下,它采用几乎黑色的颜色,而在焦点上采用原色。我试图改变它的颜色,BorderSide
但它不起作用。
我还尝试了Change TextField's Underline in Flutter for中提到的解决方法UnderlineInputBorder
,但没有任何改变。
new TextFormField(
decoration: new InputDecoration(
labelText: "Email",
contentPadding: new EdgeInsets.all(12.0),
filled: true,
border: new OutlineInputBorder(
borderSide: new BorderSide(width: 2.0, color: Colors.white),
)
),
),
解决方案
深入挖掘后,似乎只能由 ThemeData 配置。所以我只是添加了一个主题小部件。
body: Theme(data: Theme.of(context).copyWith(
primaryColor: Colors.white,
accentColor: Colors.amber
), child: new TextFormField(
decoration: new InputDecoration(
labelText: "Email",
contentPadding: new EdgeInsets.all(12.0),
),
),
input_decorator.dart#1440-1450
Color _getActiveColor(ThemeData themeData) {
if (isFocused) {
switch (themeData.brightness) {
case Brightness.dark:
return themeData.accentColor;
case Brightness.light:
return themeData.primaryColor;
}
}
return themeData.hintColor;
}
推荐阅读
- vim - 如何在 vim 插件脚本中检查“INSERT”模式或“IM INSERT”?
- angular - 在 ngOnInt 进行远程调用的单元测试
- python - 比较多维列表并返回相交索引
- javascript - 我正在尝试将 Java AES 加密解密转换为 NodeJs。这是我迄今为止尝试过的
- cs50 - CS50 Vigenere:错误的循环虽然看起来合乎逻辑?
- java - JSoup 排除表行
- arrays - SWIFT 5.1合并2个不同数据类型的数组?
- javascript - 为什么我的对话框堆叠在一起?(Vuetify)
- r - 使用 table( , sum()) 时出错。参数长度不同?
- python - 如何测量图像的饱和度?