我在我的应用中实现了numberpicker。 我想修改数字的大小以及突出显示的值和未突出显示的值的颜色。我设法修改了突出显示的内容,将其包装在“主题”小部件中并修改了accentcolor,但是不知道该如何进行其他自定义?
Theme(
data: Theme.of(context).copyWith(
accentColor: Colors.red,
),
child: NumberPicker.integer(
initialValue: _currentPickerValue,
minValue: 0,
maxValue: 100,
onChanged: (newValue) =>
setState(() => _currentPickerValue = newValue)))
答案 0 :(得分:1)
我研究了代码,这是我发现的东西
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(
headline: theme.textTheme.headline.copyWith(..), //other highlighted style
body1: theme.textTheme.headline.copyWith(...), //not highlighted styles
)),
child: NumberPicker.integer(...),
);
答案 1 :(得分:1)
将号码选择器软件包更新为最新版本。
new NumberPicker.integer(
...,
selectedTextStyle: TextStyle(...),
textStyle: TextStyle(...), //styles of the default text
)
访问NumberPickec class以获得研究属性。