Ham*_*med 6 flutter flutter-date-range-picker
我想DateRangePicker在flutter中进行自定义,如何更改以下元素?
Save按钮更改为图像。Switch to input按钮。header background颜色。day name颜色。background颜色。selected item indicator颜色。selected item text颜色。selected range indicator颜色。selected range text颜色。showDateRangePicker(
context: context,
firstDate: DateTime.now(),
lastDate: DateTime.now().add(Duration(days: 100)),
builder: (BuildContext context, Widget child) {
return Theme(
data: ThemeData(
...
),
child: child,
);
},
);
Run Code Online (Sandbox Code Playgroud)
小智 6
正如其他人之前所说,其中大多数内容只能通过修改源代码来更改。您可以通过在 showDateRangePicker 的构建器回调中应用 appBarTheme 来更改标题背景颜色。文本颜色和选择颜色也可以通过应用主题来设置,您需要使用 ColorScheme 来设置它们。此示例将标题背景设置为蓝色,关闭图标设置为白色,标题文本+所选日期文本设置为白色,选择颜色设置为红色:
final themeData = Theme.of(context);
showDateRangePicker(
context: context,
initialDateRange: initialDateRange,
firstDate: firstDate,
lastDate: lastDate,
currentDate: currentDate,
initialEntryMode: initialEntryMode,
helpText: helpText,
cancelText: cancelText,
confirmText: confirmText,
saveText: saveText,
errorFormatText: errorFormatText,
errorInvalidText: errorInvalidText,
errorInvalidRangeText: errorInvalidRangeText,
fieldStartHintText: fieldStartHintText,
fieldEndHintText: fieldEndHintText,
fieldStartLabelText: fieldStartLabelText,
fieldEndLabelText: fieldEndLabelText,
locale: locale,
useRootNavigator: useRootNavigator,
routeSettings: routeSettings,
textDirection: textDirection,
builder: (context, Widget? child) => Theme(
data: themeData.copyWith(
appBarTheme: themeData.appBarTheme.copyWith(
backgroundColor: Colors.blue,
iconTheme: themeData.appBarTheme.iconTheme!.copyWith(color: Colors.white)),
colorScheme: ColorScheme.light(
onPrimary: Colors.white,
primary: Colors.red
)),
child: child!,
));
Run Code Online (Sandbox Code Playgroud)
@Michael Feinstein 是对的 - 详细说明一下你必须做的事情:
_CalendarRangePickerDialog并更改您需要的内容。对于您的 6-9,请查看_buildDayItem范围选择器文件,其他 2 个也很容易找到:-)现在一切准备就绪,可以开始了。
| 归档时间: |
|
| 查看次数: |
13755 次 |
| 最近记录: |