diff --git a/packages/flutter/lib/src/cupertino/date_picker.dart b/packages/flutter/lib/src/cupertino/date_picker.dart index 667cce710e..d19a9ebb56 100644 --- a/packages/flutter/lib/src/cupertino/date_picker.dart +++ b/packages/flutter/lib/src/cupertino/date_picker.dart @@ -1974,6 +1974,7 @@ class _CupertinoTimerPickerState extends State { TextStyle _textStyleFrom(BuildContext context, [double magnification = 1.0]) { final TextStyle textStyle = CupertinoTheme.of(context).textTheme.pickerTextStyle; return textStyle.copyWith( + color: CupertinoDynamicColor.maybeResolve(textStyle.color, context), fontSize: textStyle.fontSize! * magnification, ); } diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 80a6f33643..1d60aa2642 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -1543,6 +1543,33 @@ void main() { // Text style should not return unresolved color. expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); }); + + testWidgets('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async { + Widget _buildTimerPicker(Brightness brightness) { + return MaterialApp( + theme: ThemeData(brightness: brightness), + home: CupertinoTimerPicker( + mode: CupertinoTimerPickerMode.hm, + onTimerDurationChanged: (Duration newDuration) {}, + initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59), + ), + ); + } + + // CupertinoTimerPicker with light theme. + await tester.pumpWidget(_buildTimerPicker(Brightness.light)); + RenderParagraph paragraph = tester.renderObject(find.text('hours')); + expect(paragraph.text.style!.color, CupertinoColors.label); + // Text style should not return unresolved color. + expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); + + // CupertinoTimerPicker with light theme. + await tester.pumpWidget(_buildTimerPicker(Brightness.dark)); + paragraph = tester.renderObject(find.text('hours')); + expect(paragraph.text.style!.color, CupertinoColors.label); + // Text style should not return unresolved color. + expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); + }); } Widget _buildPicker({