flutter - Flutter TextFormField 焦点边框颜色
问题描述
这是我的主题:
final ThemeData theme = ThemeData();
return MaterialApp(
title: 'Notes',
home: SignInPage(),
debugShowCheckedModeBanner: false,
theme: theme.copyWith(
primaryColor: Colors.green[800],
colorScheme: theme.colorScheme
.copyWith(secondary: Colors.green, secondaryVariant: Colors.green),
floatingActionButtonTheme: FloatingActionButtonThemeData(
backgroundColor: Colors.blue[900],
),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
);
在过去的颤振时代,如果您将原色设置为绿色,则焦点文本字段的边框也会变为绿色。现在,我希望我的所有文本字段在聚焦时都有一个绿色边框、绿色前缀图标和绿色标签文本,所有这些都来自根主题。但这是我使用上面的代码得到的结果:
我希望锁定、“密码”标签和边框在聚焦时全部为绿色,而在未聚焦时为灰色。如何从应用程序的根主题执行此操作。我将primaryColor设置为绿色,甚至将colorScheme辅助颜色设置为绿色,但仍然一切都是蓝色,而不是绿色。
解决方案
现在更改整个文本字段颜色的实际方法是更改 colorScheme。
colorScheme: theme.colorScheme.copyWith(
primary: Colors.green,
),
推荐阅读
- python - 有没有办法获得 for 循环的第一个结果?
- javascript - Javascript 计时器比 php mysql 晚 5 小时
- c++ - 在 C++ 中的模板类中创建向量
- python - 使用 Cython 对 Python 进行性能优化
- rust - 向量
,整数向量与字符串向量,为什么即使元素在堆上,我也可以索引/复制 int 元素? - angular - angular - 当数组过滤器完成时分配一个变量
- python - 创建具有指定 RGB 值的颜色图
- java - JComboBox 选择的索引更改用于使用按钮单击事件将不同的 JTextField 值发送到 JTable
- angular - 在整个应用程序中颤动变化数据,如角度行为主题
- java - SpringBoot 2.x 战争部署在 websphere 8.5.5.11 上失败并出现 jar 问题