【发布时间】:2020-09-27 10:54:51
【问题描述】:
我正在尝试更改日期选择器的颜色,但其中仍有蓝色。我尝试了很多,但我找不到改变蓝色的代码(见下文)。
文本:输入日期、下划线和取消和确定按钮都应该是青色。
到目前为止,这是我的代码。感谢支持!
TextEditingController _dateController = new TextEditingController();
DateTime selectedDate = DateTime.now();
var myFormat = DateFormat('d-MM-yyyy');
Future<void> _selectDate(BuildContext context) async {
final DateTime picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime(1930),
lastDate: DateTime(2022),
builder: (BuildContext context, Widget child) {
return Theme(
data: ThemeData.light().copyWith(
colorScheme: ColorScheme.fromSwatch(
primarySwatch: Colors.teal,
primaryColorDark: Colors.teal,
accentColor: Colors.teal,
),
dialogBackgroundColor:Colors.white,
),
child: child,
);
},
);
if (picked != null && picked != selectedDate)
setState(() {
selectedDate = picked;
});
}
【问题讨论】:
-
没有办法做到这一点,我能看到的唯一解决方案是在您的项目中添加 Flutter Date Picker 类并对其进行修改。