mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
parent
f5865e5cdb
commit
bd2ca58db3
@ -281,11 +281,12 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final TextStyle textStyle = CupertinoTheme.of(context).textTheme.pickerTextStyle;
|
||||
final Color? resolvedBackgroundColor = CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context);
|
||||
|
||||
assert(RenderListWheelViewport.defaultPerspective == _kDefaultPerspective);
|
||||
final Widget result = DefaultTextStyle(
|
||||
style: CupertinoTheme.of(context).textTheme.pickerTextStyle,
|
||||
style: textStyle.copyWith(color: CupertinoDynamicColor.maybeResolve(textStyle.color, context)),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Positioned.fill(
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@ -423,6 +424,46 @@ void main() {
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
});
|
||||
|
||||
testWidgets('Picker adapts to MaterialApp dark mode', (WidgetTester tester) async {
|
||||
Widget _buildCupertinoPicker(Brightness brightness) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(brightness: brightness),
|
||||
home: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
height: 300.0,
|
||||
width: 300.0,
|
||||
child: CupertinoPicker(
|
||||
itemExtent: 50.0,
|
||||
onSelectedItemChanged: (_) { },
|
||||
children: List<Widget>.generate(3, (int index) {
|
||||
return SizedBox(
|
||||
height: 50.0,
|
||||
width: 300.0,
|
||||
child: Text(index.toString()),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// CupertinoPicker with light theme.
|
||||
await tester.pumpWidget(_buildCupertinoPicker(Brightness.light));
|
||||
RenderParagraph paragraph = tester.renderObject(find.text('1'));
|
||||
expect(paragraph.text.style!.color, CupertinoColors.label);
|
||||
// Text style should not return unresolved color.
|
||||
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
|
||||
|
||||
// CupertinoPicker with dark theme.
|
||||
await tester.pumpWidget(_buildCupertinoPicker(Brightness.dark));
|
||||
paragraph = tester.renderObject(find.text('1'));
|
||||
expect(paragraph.text.style!.color, CupertinoColors.label);
|
||||
// Text style should not return unresolved color.
|
||||
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
|
||||
});
|
||||
|
||||
group('CupertinoPickerDefaultSelectionOverlay', () {
|
||||
testWidgets('should be using directional decoration', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user