【发布时间】:2021-08-07 07:37:27
【问题描述】:
下面附上我当前更改 CupertinoDatePicker 文本颜色的代码:
Container(
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(12)),
height: MediaQuery.of(context).size.height * 0.18,
child: CupertinoTheme(
data: CupertinoThemeData(
textTheme: CupertinoTextThemeData(
pickerTextStyle: TextStyle(
color: Color(0xffB59CCF),
)),
),
child: CupertinoDatePicker(
但是颜色并没有改变,如下图:
我在 main.dart 中的主题如下:
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
bodyText1: TextStyle(),
bodyText2: TextStyle(),
).apply(
bodyColor: Colors.white.withOpacity(0.87),
displayColor: Colors.white.withOpacity(0.87)),
primaryColor: Colors.white,
secondaryHeaderColor: Colors.white.withOpacity(0.60),
backgroundColor: Color(0xff111016),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.all(15),
shape: CircleBorder(),
elevation: 6,
onPrimary: Color(0xff04072E),
primary: Colors.yellow[100],
textStyle: TextStyle(fontSize: 21)),
),
我不确定是什么原因导致 CupertinoDatePicker 的文本颜色为黑色,但我希望它改变颜色。任何帮助表示赞赏!谢谢!
改成dateTimePickerTextStyle后,出现如下情况:
【问题讨论】:
标签: flutter date flutter-cupertino