fix MediaQuery override in CupertinoDatePicker (#48001)
This commit is contained in:
parent
c924f499f5
commit
7511d8c06a
@ -777,7 +777,7 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: const MediaQueryData(textScaleFactor: 1.0),
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
||||||
child: DefaultTextStyle.merge(
|
child: DefaultTextStyle.merge(
|
||||||
style: _kDefaultPickerTextStyle,
|
style: _kDefaultPickerTextStyle,
|
||||||
child: CustomMultiChildLayout(
|
child: CustomMultiChildLayout(
|
||||||
@ -1145,7 +1145,7 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: const MediaQueryData(textScaleFactor: 1.0),
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
||||||
child: DefaultTextStyle.merge(
|
child: DefaultTextStyle.merge(
|
||||||
style: _kDefaultPickerTextStyle,
|
style: _kDefaultPickerTextStyle,
|
||||||
child: CustomMultiChildLayout(
|
child: CustomMultiChildLayout(
|
||||||
@ -1669,11 +1669,9 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
}
|
}
|
||||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: const MediaQueryData(
|
// The native iOS picker's text scaling is fixed, so we will also fix it
|
||||||
// The native iOS picker's text scaling is fixed, so we will also fix it
|
// as well in our picker.
|
||||||
// as well in our picker.
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
||||||
textScaleFactor: 1.0,
|
|
||||||
),
|
|
||||||
child: CupertinoTheme(
|
child: CupertinoTheme(
|
||||||
data: themeData.copyWith(
|
data: themeData.copyWith(
|
||||||
textTheme: themeData.textTheme.copyWith(
|
textTheme: themeData.textTheme.copyWith(
|
||||||
|
@ -1187,6 +1187,51 @@ void main() {
|
|||||||
handle.dispose();
|
handle.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('CupertinoDataPicker does not provide invalid MediaQuery', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/47989.
|
||||||
|
Brightness brightness = Brightness.light;
|
||||||
|
StateSetter setState;
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
CupertinoApp(
|
||||||
|
theme: const CupertinoThemeData(
|
||||||
|
textTheme: CupertinoTextThemeData(
|
||||||
|
dateTimePickerTextStyle: TextStyle(
|
||||||
|
color: CupertinoDynamicColor.withBrightness(
|
||||||
|
color: Color(0xFFFFFFFF),
|
||||||
|
darkColor: Color(0xFF000000),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
home: StatefulBuilder(builder: (BuildContext context, StateSetter stateSetter) {
|
||||||
|
setState = stateSetter;
|
||||||
|
return MediaQuery(
|
||||||
|
data: MediaQuery.of(context).copyWith(platformBrightness: brightness),
|
||||||
|
child: CupertinoDatePicker(
|
||||||
|
initialDateTime: DateTime(2019),
|
||||||
|
mode: CupertinoDatePickerMode.date,
|
||||||
|
onDateTimeChanged: (DateTime date) {},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
tester.widget<Text>(find.text('2019')).style.color,
|
||||||
|
isSameColorAs(const Color(0xFFFFFFFF)),
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() { brightness = Brightness.dark; });
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
tester.widget<Text>(find.text('2019')).style.color,
|
||||||
|
isSameColorAs(const Color(0xFF000000)),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('picker exports semantics', (WidgetTester tester) async {
|
testWidgets('picker exports semantics', (WidgetTester tester) async {
|
||||||
final SemanticsHandle handle = tester.ensureSemantics();
|
final SemanticsHandle handle = tester.ensureSemantics();
|
||||||
debugResetSemanticsIdCounter();
|
debugResetSemanticsIdCounter();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user