dart - 如何在 Flutter 中自定义 numberpicker?
问题描述
我在我的应用程序中实现了 numberpicker。我想修改数字的大小以及突出显示的值和未突出显示的值的颜色。我设法修改了将其包装在主题小部件中的突出显示部分并修改了强调色,但不知道如何进行其他自定义?
Theme(
data: Theme.of(context).copyWith(
accentColor: Colors.red,
),
child: NumberPicker.integer(
initialValue: _currentPickerValue,
minValue: 0,
maxValue: 100,
onChanged: (newValue) =>
setState(() => _currentPickerValue = newValue)))
解决方案
我深入研究了代码,这是我发现的
selectedStyle = themeData.textTheme.headline.copyWith(color: themeData.accentColor);
defaultStyle = themeData.textTheme.body1;
这是未突出显示的
更改大小或颜色或任何其他样式属性修改这些样式。
这是一个示例代码:
final theme = Theme.of(context);
Theme(
data: theme.copyWith(
accentColor: Colors.black,// highlted color
textTheme: theme.textTheme.copyWith(
headline5: theme.textTheme.headline5.copyWith(..), //other highlighted style
bodyText2: theme.textTheme.headline5.copyWith(...), //not highlighted styles
)),
child: NumberPicker.integer(...),
);
推荐阅读
- java - Selenium 拖放问题
- css - 如何在分屏中禁用 100vh 的滚动条?
- r - 如何随机删除数据框中的行,但仅针对特定子组(使用 dplyr::sample_n?)
- firebase - 如何从 Flutter 的 DateTimePicker 中保存 DateTime 并将其作为时间戳写入 Firebase
- c++ - HANDLE 的 Boost 等价物是什么?
- vue.js - Vue 没有卸载有条件渲染的组件
- fullcalendar - 如何在 FullCalendar 中使用 CSS 显示和/或隐藏事件?
- c++ - 使用 B+ 树索引实现内存存储
- python - 根据其他数据框中的值填充一个数据框中的值
- python - Python算法提速/性能提示