fix(CupertinoDatePicker): font is inconsistent (#162932)
This request fixes the issue where the missing font parameter for
rendering the year caused its font to be inconsistent, leading to visual
misalignment.
829fe68e9d/packages/flutter/lib/src/cupertino/date_picker.dart (L1454-L1461)
- Fixes https://github.com/flutter/flutter/issues/161773
## 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.
This commit is contained in:
parent
ed71f924b1
commit
e0617ac362
@ -1458,6 +1458,7 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
|
||||
useMagnifier: _kUseMagnifier,
|
||||
magnification: _kMagnification,
|
||||
backgroundColor: widget.backgroundColor,
|
||||
squeeze: _kSqueeze,
|
||||
onSelectedItemChanged: (int index) {
|
||||
selectedYear = index;
|
||||
if (_isCurrentDateValid) {
|
||||
|
@ -2487,6 +2487,31 @@ void main() {
|
||||
expect(testWidth, equals(largestWidth));
|
||||
expect(widths.indexOf(largestWidth), equals(1));
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/39998
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/161773
|
||||
testWidgets('CupertinoDatePicker date value baseline alignment', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: SizedBox(
|
||||
width: 400,
|
||||
height: 400,
|
||||
child: CupertinoDatePicker(
|
||||
mode: CupertinoDatePickerMode.date,
|
||||
onDateTimeChanged: (_) {},
|
||||
initialDateTime: DateTime(2025, 2, 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Offset lastOffset = tester.getTopLeft(find.text('November'));
|
||||
expect(tester.getTopLeft(find.text('11')).dy, lastOffset.dy);
|
||||
|
||||
lastOffset = tester.getTopLeft(find.text('11'));
|
||||
expect(tester.getTopLeft(find.text('2022')).dy, lastOffset.dy);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildPicker({
|
||||
|
Loading…
x
Reference in New Issue
Block a user