Skip to content

Commit 4a6965c

Browse files
Docs: Update date picker theme day color properties doc (flutter#166122)
Docs: Update date picker theme day color properties doc fixes: flutter#161052 Part 2 of flutter#164972 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. --------- Co-authored-by: Qun Cheng <36861262+QuncCccccc@users.noreply.github.com>
1 parent c74cd04 commit 4a6965c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

packages/flutter/lib/src/material/date_picker_theme.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,64 @@ class DatePickerThemeData with Diagnosticable {
165165
/// grid of the date picker.
166166
///
167167
/// This will be used instead of the color provided in [dayStyle].
168+
///
169+
/// This supports different colors based on the [WidgetState]s of
170+
/// the day button, such as `WidgetState.selected`, `WidgetState.hovered`,
171+
/// `WidgetState.focused`, and `WidgetState.disabled`.
172+
///
173+
/// ```dart
174+
/// dayBackgroundColor: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
175+
/// if (states.contains(WidgetState.selected)) {
176+
/// return Theme.of(context).colorScheme.primary;
177+
/// }
178+
/// return null; // Use the default color.
179+
/// })
180+
/// ```
181+
///
182+
/// See also:
183+
/// * [dayOverlayColor] which applies an overlay over the day labels depending on the [WidgetState].
168184
final WidgetStateProperty<Color?>? dayForegroundColor;
169185

170186
/// Overrides the default color used to paint the background of the
171187
/// day labels in the grid of the date picker.
188+
///
189+
/// This supports different colors based on the [WidgetState]s of
190+
/// the day button, such as `WidgetState.selected`, `WidgetState.hovered`,
191+
/// `WidgetState.focused`, and `WidgetState.disabled`.
192+
///
193+
/// ```dart
194+
/// dayBackgroundColor: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
195+
/// if (states.contains(WidgetState.selected)) {
196+
/// return Theme.of(context).colorScheme.primary;
197+
/// }
198+
/// return null; // Use the default color.
199+
/// })
200+
/// ```
201+
/// See also:
202+
/// * [dayOverlayColor] which applies an overlay over the day labels depending on the [WidgetState].
172203
final WidgetStateProperty<Color?>? dayBackgroundColor;
173204

174205
/// Overrides the default highlight color that's typically used to
175206
/// indicate that a day in the grid is focused, hovered, or pressed.
207+
///
208+
/// This supports different colors based on the [WidgetState]s of
209+
/// the day button. The overlay color is usually used with an opacity to
210+
/// create hover, focus, and press effects.
211+
///
212+
/// ```dart
213+
/// dayOverlayColor: WidgetStateProperty.resolveWith((Set<WidgetState> states) {
214+
/// if (states.contains(WidgetState.pressed)) {
215+
/// return Colors.blue.withOpacity(0.12);
216+
/// }
217+
/// if (states.contains(WidgetState.hovered)) {
218+
/// return Colors.blue.withOpacity(0.08);
219+
/// }
220+
/// if (states.contains(WidgetState.focused)) {
221+
/// return Colors.blue.withOpacity(0.12);
222+
/// }
223+
/// return null; // Use the default color.
224+
/// })
225+
/// ```
176226
final WidgetStateProperty<Color?>? dayOverlayColor;
177227

178228
/// Overrides the default shape used to paint the shape decoration of the

0 commit comments

Comments
 (0)