dayPeriodColor property

Color? get dayPeriodColor

The background color of the AM/PM toggle.

If dayPeriodColor is a WidgetStateColor, then the effective background color can depend on the WidgetState.selected state, i.e. if the segment is selected or not.

By default, if the segment is selected, the overall theme's ColorScheme.primary.withValues(alpha: 0.12) is used when the overall theme's brightness is Brightness.light and ColorScheme.primary.withValues(alpha: 0.24) is used when the overall theme's brightness is Brightness.dark. If the segment is not selected, Colors.transparent is used to allow the Dialog's color to be used.

Implementation

Color? get dayPeriodColor {
  if (_dayPeriodColor == null || _dayPeriodColor is WidgetStateColor) {
    return _dayPeriodColor;
  }
  return WidgetStateColor.resolveWith((Set<WidgetState> states) {
    if (states.contains(WidgetState.selected)) {
      return _dayPeriodColor;
    }
    // The unselected day period should match the overall picker dialog color.
    // Making it transparent enables that without being redundant and allows
    // the optional elevation overlay for dark mode to be visible.
    return Colors.transparent;
  });
}