Skip to content

modify toggle mode style with DatePickerTheme - #164102

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
MaironLucas:163866
Apr 11, 2025
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
MaironLucas:163866

Conversation

@MaironLucas

@MaironLucas MaironLucas commented Feb 25, 2025 •

Copy link
Copy Markdown
Contributor
  • Add properties to DatePickerThemeData:
    • toggleModeStyle allow customization on _DatePickerModeToggleButton TextStyle;
    • toggleModeForegroundColor allow changing the color of both button and Icon with consistency;
  • Compatible with existing code by the use of defaults;
  • Adjust test to cover new properties

How to customize toggle mode style before:

  showDatePicker(
    context: context,
    firstDate: DateTime(2025),
    lastDate: DateTime(2026),
    builder:
        (context, child) => Theme(
          data: ThemeData.light().copyWith(
            textTheme: TextTheme(titleSmall: TextStyle(fontSize: 16)),
            datePickerTheme: DatePickerThemeData(
              dayStyle: TextStyle(fontSize: 12),
            ),
          ),
          child: child!,
        ),
  );

Now:

  showDatePicker(
    context: context,
    firstDate: DateTime(2025),
    lastDate: DateTime(2026),
    builder:
        (context, child) => DatePickerTheme(
          data: DatePickerThemeData(
            toggleModeStyle: TextStyle(fontSize: 16),
            dayStyle: TextStyle(fontSize: 12),
          ),
          child: child!,
        ),
  );

Ref #163866
Ref #160591

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DatePickerThemeData] doesn't allow changes to the sub-header styling

3 participants