Add timeSelectorSeparatorColor and timeSelectorSeparatorTextStyle for Material 3 Time Picker (#143739)
fixes [`Time selector separator` in TimePicker is not centered vertically](https://github.com/flutter/flutter/issues/143691) Separator currently `hourMinuteTextStyle` to style itself. This introduces `timeSelectorSeparatorColor` and `timeSelectorSeparatorTextStyle` from Material 3 specs to correctly style the separator. This also adds ability to change separator color without changing `hourMinuteTextColor`. ### Specs for the time selector separator https://m3.material.io/components/time-pickers/specs  ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() { runApp(const App()); } class App extends StatelessWidget { const App({super.key}); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( // timePickerTheme: TimePickerThemeData( // hourMinuteTextColor: Colors.amber, // ) ), home: Scaffold( body: Center( child: Builder(builder: (context) { return ElevatedButton( onPressed: () async { await showTimePicker( context: context, initialTime: TimeOfDay.now(), ); }, child: const Text('Pick Time'), ); }), ), ), ); } } ``` </details> | Before | After | | --------------- | --------------- | | <img src="https://github.com/flutter/flutter/assets/48603081/20beeba4-5cc2-49ee-bba8-1c552c0d1e44" /> | <img src="https://github.com/flutter/flutter/assets/48603081/24927187-aff7-4191-930c-bceab6a4b4c2" /> |
This commit is contained in:
@@ -333,6 +333,20 @@ class _${blockName}DefaultsM3 extends _TimePickerDefaults {
|
||||
ShapeBorder get shape {
|
||||
return ${shape("$tokenGroup.container")};
|
||||
}
|
||||
|
||||
@override
|
||||
MaterialStateProperty<Color?>? get timeSelectorSeparatorColor {
|
||||
// TODO(tahatesser): Update this when tokens are available.
|
||||
// This is taken from https://m3.material.io/components/time-pickers/specs.
|
||||
return MaterialStatePropertyAll<Color>(_colors.onSurface);
|
||||
}
|
||||
|
||||
@override
|
||||
MaterialStateProperty<TextStyle?>? get timeSelectorSeparatorTextStyle {
|
||||
// TODO(tahatesser): Update this when tokens are available.
|
||||
// This is taken from https://m3.material.io/components/time-pickers/specs.
|
||||
return MaterialStatePropertyAll<TextStyle?>(_textTheme.displayLarge);
|
||||
}
|
||||
}
|
||||
''';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user